forked from Goles/dotvim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bindings
110 lines (95 loc) · 4 KB
/
bindings
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""
""" Ben Bleything's Vim Setup
""" Based on the work of many others. See README.rdoc for credits.
"""
""" Git Hubs: http://github.com/bleything/dotvim
""" Internet Electronic Mail: [email protected]
"""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""" K E Y B I N D I N G S
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let mapleader=',' " set leader to ,
" Set markdown files for .md files
au BufRead,BufNewFile *.md set filetype=markdown
" format paragraphs (72 columns)
"map ^^ {!}par w72qrg<CR>
inoremap <leader>,l <C-x><C-o>
" one-stroke window maximizing
map <C-H> <C-W>h<C-W><BAR>
map <C-L> <C-W>l<C-W><BAR>
map <C-J> <C-W>j<C-W>_
map <C-K> <C-W>k<C-W>_
" quick buffer switching
noremap <c-[> <Esc>:bp<CR>
noremap <c-]> <Esc>:bn<CR>
" shortcut to strip trailing whitespace
map <leader>s :s/\s\+$//g<CR>
"" Map escape key to kj
inoremap lh <Esc>
"" Disable the arrow keys! :D
" noremap <Up> ""
" noremap! <Up> <Esc>
" noremap <Down> ""
" noremap! <Down> <Esc>
" noremap <Left> ""
" noremap! <Left> <Esc>
" noremap <Right> ""
" noremap! <Right> <Esc>
""" Tab mappings
nnoremap <silent> <C-g> :tabnew<CR>
nnoremap <silent> <C-h> :tabprevious<CR>
nnoremap <silent> <C-l> :tabnext<CR>
"" To execute shell commands taken from :Shell
"" http://vim.wikia.com/wiki/Display_output_of_shell_commands_in_new_window
let s:_ = ''
function! s:ExecuteInShell(command, bang)
let _ = a:bang != '' ? s:_ : a:command == '' ? '' : join(map(split(a:command), 'expand(v:val)'))
if (_ != '')
let s:_ = _
let bufnr = bufnr('%')
let winnr = bufwinnr('^' . _ . '$')
silent! execute winnr < 0 ? 'belowright new ' . fnameescape(_) : winnr . 'wincmd w'
setlocal buftype=nowrite bufhidden=wipe nobuflisted noswapfile wrap number
silent! :%d
let message = 'Execute ' . _ . '...'
call append(0, message)
echo message
silent! 2d | resize 1 | redraw
silent! execute 'silent! %!'. _
silent! execute 'resize ' . line('$')
silent! execute 'syntax on'
silent! execute 'autocmd BufUnload <buffer> execute bufwinnr(' . bufnr . ') . ''wincmd w'''
silent! execute 'autocmd BufEnter <buffer> execute ''resize '' . line(''$'')'
silent! execute 'nnoremap <silent> <buffer> <CR> :call <SID>ExecuteInShell(''' . _ . ''', '''')<CR>'
silent! execute 'nnoremap <silent> <buffer> <LocalLeader>r :call <SID>ExecuteInShell(''' . _ . ''', '''')<CR>'
silent! execute 'nnoremap <silent> <buffer> <LocalLeader>g :execute bufwinnr(' . bufnr . ') . ''wincmd w''<CR>'
nnoremap <silent> <buffer> <C-W>_ :execute 'resize ' . line('$')<CR>
silent! syntax on
endif
endfunction
command! -complete=shellcmd -nargs=* -bang Shell call s:ExecuteInShell(<q-args>, '<bang>')
command! -complete=shellcmd -nargs=* -bang BuildDevice call s:ExecuteInShell('xcodebuild -sdk iphoneos build', '<bang>')
command! -complete=shellcmd -nargs=* -bang BuildSimulator call s:ExecuteInShell('xcodebuild -sdk iphonesimulator6.0 build', '<bang>')
command! -complete=shellcmd -nargs=* -bang RunDevice call s:ExecuteInShell("fruitstrap -d -b build/Release-iphoneos/*.app", '<bang>')
command! -complete=shellcmd -nargs=* -bang RunSimulator call s:ExecuteInShell("ios-sim launch build/Release-iphonesimulator/*.app", '<bang>')
cabbrev shell Shell
" My tab mappings
function! TabMappings()
if pumvisible()
return "\<C-n>"
elseif &ft == 'c'
return "\<C-X>\<C-U>"
elseif &ft == 'c++'
return "\<C-X>\<C-U>"
elseif &ft == 'objc'
return "\<C-X>\<C-U>"
elseif &ft == 'objcpp'
return "\<C-X>\<C-U>"
" elseif neocomplcache#sources#snippets_complete#expandable()
" return "\<Plug>(neocomplcache_snippets_expand)"
endif
endfunction
imap <expr><TAB> TabMappings()
imap <C-a> <Plug>(neocomplcache_snippets_expand)