Created
August 9, 2011 14:59
-
-
Save jcmuller/1134279 to your computer and use it in GitHub Desktop.
Useful vim key mappings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""""""""""""""""""""""" | |
" Useful maps | |
"""""""""""""""""""""""" | |
" Map <C-L> (redraw screen) to also turn off search highlighting until the | |
" next search | |
nnoremap <C-L> :nohl<CR><C-L> | |
" Don't use arrow keys | |
map <up> <nop> | |
map <down> <nop> | |
map <left> <nop> | |
map <right> <nop> | |
nmap <Leader>a :Ack | |
" Run ack against the visually selected text | |
nmap <Leader>A vaw"ay:Ack <C-R>a | |
" Automatically add closing ( { [ ' " ` | |
inoremap {<cr> {<cr>}<ESC>kA<CR> | |
inoremap { {}<ESC>i | |
inoremap ( ()<ESC>i | |
inoremap [ []<ESC>i | |
au FileType html,vim,xhtml,xml inoremap < <lt>><ESC>i| inoremap > <c-r>=ClosePair('>')<CR> | |
" Search | |
noremap ;; :%s:::g<Left><Left><Left> | |
noremap ;' :%s:::gc<Left><Left><Left><Left> | |
" Select previously pasted text | |
nnoremap <expr> gp '`[' . strpart(getregtype(), 0, 1) . '`]' | |
" Emacs motion commands | |
noremap! <C-A> <Home> | |
noremap! <C-E> <End> | |
cnoremap <C-K> <C-U> | |
noremap! <C-F> <Right> | |
noremap! <C-B> <Left> | |
" Saving quicker | |
" Normal mode | |
nnoremap ;w :w<cr> | |
" Insert mode: Ctrl-S | |
inoremap <C-S> <Esc>:w<cr>i |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Search visually selected text | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
vmap * :<C-u>call <SID>VSetSearch()<CR>/<CR> | |
vmap # :<C-u>call <SID>VSetSearch()<CR>?<CR> | |
func! s:VSetSearch() | |
let temp = @@ | |
norm! gvy | |
let @/ = '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g') | |
let @@ = temp | |
endf |
I'd be interested in your thought on html tags like
<div class="container">
<div class="row">
<div class="col-12">
I'm thinking:
<dd
<dr
<dc
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
can you map newtabe?