-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc.mappings
94 lines (77 loc) · 2.27 KB
/
vimrc.mappings
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
" vim: foldmethod=marker ts=2 sts=2 sw=2 fdl=0
" functions {{{
function! Preserve(command)
" preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" do the business:
execute a:command
" clean up: restore previous search history, and cursor position
let @/=_s
call cursor(l, c)
endfunction
function! StripTrailingWhitespace()
call Preserve("%s/\\s\\+$//e")
endfunction
"}}}
nmap <leader>fef :call Preserve("normal gg=G")<CR>
nmap <leader>f$ :call StripTrailingWhitespace()<CR>
nnoremap <leader>w :w<cr>
"awesome, inserts new line without going into insert mode
map <S-Enter> O<ESC>
map <Enter> o<ESC>
" toggle paste
map <F6> :set invpaste<CR>:set paste?<CR>
" smash escape
inoremap fd <esc>
inoremap jj <esc>
inoremap <esc> <Nop>
inoremap <C-]> <C-o>l
" cscope
nmap <C-[>s :cs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-[>g :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-[>c :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-[>t :cs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-[>e :cs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-[>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-[>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-[>d :cs find d <C-R>=expand("<cword>")<CR><CR>
" folds
nnoremap zr zr:echo &foldlevel<cr>
nnoremap zm zm:echo &foldlevel<cr>
nnoremap zR zR:echo &foldlevel<cr>
nnoremap zM zM:echo &foldlevel<cr>
" screen line scroll
nnoremap <silent> j gj
nnoremap <silent> k gk
" find current word in quickfix
nnoremap <leader>fw :execute "vimgrep ".expand("<cword>")." %"<cr>:copen<cr>
" find last search in quickfix
nnoremap <leader>ff :execute 'vimgrep /'.@/.'/g %'<cr>:copen<cr>
" shortcuts for windows
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" hide annoying quit message
nnoremap <C-c> <C-c>:echo<cr>
" quick buffer open
nnoremap gb :ls<cr>:e #
" disable arrow keys
map <Left> <Nop>
map <Right> <Nop>
map <Up> <Nop>
map <Down> <Nop>
imap <Up> <Nop>
imap <Down> <Nop>
imap <Left> <Nop>
imap <Right> <Nop>
" surround a word with some character
function! s:surround()
let word = expand("<cword>")
let wrap= input("wrap with: ")
let command = "s/".word."/".wrap.word.wrap."/"
execute command
endfunction
nmap cx :call <SID>surround()<CR>