comparison vimrc @ 85:8a5464ec3c29

Add vim mappings from https://bitbucket.org/sjl/dotfiles
author zegervdv <zegervdv@me.com>
date Thu, 31 Jul 2014 21:38:35 +0200
parents 5fd16ed8bb6d
children aefa231684d9
comparison
equal deleted inserted replaced
84:d282fe62a215 85:8a5464ec3c29
51 51
52 set history=100 52 set history=100
53 set wildmenu 53 set wildmenu
54 set wildmode=full 54 set wildmode=full
55 set ttyfast 55 set ttyfast
56 set lazyredraw
56 57
57 set diffopt+=iwhite 58 set diffopt+=iwhite
58 59
59 set tags=.git/tags 60 set tags=.git/tags
60 61
83 set viminfo='10,\"100,:20,%,n~/.viminfo 84 set viminfo='10,\"100,:20,%,n~/.viminfo
84 85
85 set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.o,*.bin,*.elf,*.hex 86 set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.o,*.bin,*.elf,*.hex
86 87
87 " set list 88 " set list
88 " set listchars=tab:▸\ ,eol:¬ 89 set listchars=tab:▸\ ,eol:¬
89 " }}} 90 " }}}
90 " Custom remaps and tricks {{{ 91 " Custom remaps and tricks {{{
91 " When editing a file, always jump to the last known cursor position. 92 " When editing a file, always jump to the last known cursor position.
92 " Don't do it for commit messages, when the position is invalid, or when 93 " Don't do it for commit messages, when the position is invalid, or when
93 " inside an event handler (happens when dropping a file on gvim). 94 " inside an event handler (happens when dropping a file on gvim).
106 " See long lines as line breaks 107 " See long lines as line breaks
107 map j gj 108 map j gj
108 map k gk 109 map k gk
109 110
110 " remap tag-search to better place 111 " remap tag-search to better place
111 nmap <C-$> <C-]> 112 " nmap <C-$> <C-]>
113 function! JumpToTagInSplit()
114 execute "normal! \<c-w>v\<c-]>mzzMzvzz15\<c-e>"
115 execute "keepjumps normal! `z"
116 Pulse
117 endfunction
118 nnoremap <c-$> :silent! call JumpToTag()<cr>
112 119
113 " Jump to end of line in insert mode 120 " Jump to end of line in insert mode
114 inoremap <C-a> <C-o>I 121 inoremap <C-a> <C-o>I
115 inoremap <C-e> <C-o>A 122 inoremap <C-e> <C-o>A
116 123
127 134
128 " Very Magic search patterns 135 " Very Magic search patterns
129 nmap / /\v 136 nmap / /\v
130 cmap s/ s/\v 137 cmap s/ s/\v
131 138
139 " Keep search matches in the middle of the window.
140 nnoremap n nzzzv
141 nnoremap N Nzzzv
142
143 " Show local search results in quickfix
144 nnoremap <silent> <leader>/ :execute 'vimgrep /'.@/.'/g %'<CR>:copen<CR>
145 nnoremap <silent> <leader>? :Ag <cword><CR>
146 " nnoremap <silent> <leader>? :execute "Ag! '" . substitute(substitute(substitute(@/, "\\\\<", "\\\\b", ""), "\\\\>", "\\\\b", ""), "\\\\v", "","") . "'"<CR>
147
132 " Clear highlight 148 " Clear highlight
133 nnoremap <silent> <leader>n :nohlsearch<CR> 149 nnoremap <silent> <leader>n :nohlsearch<CR>
134 150
135 inoremap £ \ 151 inoremap £ \
136 152
137 nnoremap <TAB> % 153 nnoremap <TAB> %
138 vnoremap <TAB> % 154 vnoremap <TAB> %
139 155
140 " Move between windows 156 " Move between tabs
141 nnoremap <C-l> <C-w><C-l>
142 nnoremap <C-h> <C-w><C-h>
143 nnoremap <C-j> <C-w>j
144 nnoremap <C-k> <C-w><C-k>
145
146 nnoremap <S-j> :tabprevious<CR> 157 nnoremap <S-j> :tabprevious<CR>
147 nnoremap <S-k> :tabnext<CR> 158 nnoremap <S-k> :tabnext<CR>
148 nnoremap <S-h> :tabfirst<CR> 159 nnoremap <S-h> :tabfirst<CR>
149 nnoremap <S-l> :tablast<CR> 160 nnoremap <S-l> :tablast<CR>
150 nnoremap <S-t> :tabnew<CR> 161 nnoremap <S-t> :tabnew<CR>
168 exec 'sleep ' . float2nr(a:blinktime * 1000) . 'm' 179 exec 'sleep ' . float2nr(a:blinktime * 1000) . 'm'
169 call matchdelete(ring) 180 call matchdelete(ring)
170 redraw 181 redraw
171 endfunction 182 endfunction
172 183
184 " Highlight VCS conflict markers
185 match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$'
186
173 " Swap v and CTRL-V 187 " Swap v and CTRL-V
174 nnoremap v <C-V> 188 nnoremap v <C-V>
175 nnoremap <C-V> v 189 nnoremap <C-V> v
176 190
177 vnoremap v <C-V> 191 vnoremap v <C-V>
198 highlight IndentGuidesEven guibg=background 212 highlight IndentGuidesEven guibg=background
199 highlight IndentGuidesOdd guibg='#282a2e' 213 highlight IndentGuidesOdd guibg='#282a2e'
200 214
201 au FileType c setl foldmethod=syntax 215 au FileType c setl foldmethod=syntax
202 216
217 au VimResized * exe "normal! \<c-w>="
218
219 cnoremap <c-a> <home>
220 cnoremap <c-e> <end>
221
222 " Swap backticks and quotes
223 nnoremap ` '
224 nnoremap ' `
225
226 " Note that this will overwrite the contents of the z mark. I never use it, but
227 " if you do you'll probably want to use another mark.
228 inoremap <C-u> <esc>mzgUiw`za
229
230 nnoremap <leader>ev :vsplit $MYVIMRC<cr>
231
232 function! MyFoldText() " {{{
233 let line = getline(v:foldstart)
234
235 let nucolwidth = &fdc + &number * &numberwidth
236 let windowwidth = winwidth(0) - nucolwidth - 3
237 let foldedlinecount = v:foldend - v:foldstart
238
239 " expand tabs into spaces
240 let onetab = strpart(' ', 0, &tabstop)
241 let line = substitute(line, '\t', onetab, 'g')
242
243 let line = strpart(line, 0, windowwidth - 2 -len(foldedlinecount))
244 let fillcharcount = windowwidth - len(line) - len(foldedlinecount)
245 return line . '…' . repeat(" ",fillcharcount) . foldedlinecount . '…' . ' '
246 endfunction " }}}
247 set foldtext=MyFoldText()
203 248
204 " }}} 249 " }}}
205 250
206 " Vim Math plugin; make simple calculations {{{ 251 " Vim Math plugin; make simple calculations {{{
207 vmap <expr> ++ VMATH_YankAndAnalyse() 252 vmap <expr> ++ VMATH_YankAndAnalyse()
424 " Load local vimrc 469 " Load local vimrc
425 if filereadable($HOME . "/.vimrc.local") 470 if filereadable($HOME . "/.vimrc.local")
426 source ~/.vimrc.local 471 source ~/.vimrc.local
427 endif 472 endif
428 473
429 nnoremap <Enter> o<ESC>