4 ms·
Search/replace the word under the cursor in the current paragraph (for <leader>r) or the whole buffer (for <leader>R). Beats the crap out of "multiple cursors"
by johncoltrane 13y ago
Search/replace the word under the cursor in the current paragraph (for <leader>r) or the whole buffer (for <leader>R). Beats the crap out of "multiple cursors" in the typical "change a variable name" example:
nnoremap ,r :'{,'}s/\<<C-r>=expand('<cword>')<CR>\>/
nnoremap ,R :%s/\<<C-r>=expand('<cword>')<CR>\>/
Another approach of the typical "multiple cursors" example, using the beautiful gn command. Hit ,x to "change" the word under the cursor then <Esc> and repeat for the next occurrences with the dot (or n to skip):
nnoremap ,x *``cgn
nnoremap ,X #``cgN
Move to next and previous quickfix error:
nnoremap <End> :cnext<CR>zv
nnoremap <Home> :cprevious<CR>zv
Traverse the buffer list effortlessly:
nnoremap <PageUp> :bp<CR>
nnoremap <PageDown> :bn<CR>
In my lightweight "noplugin" vimrc (used on remote machines) I have these as well:
set wildcharm=<C-z>
set path=.,**
" juggling with files
nnoremap ,f :find<Space>
nnoremap ,s :sfind<Space>
nnoremap ,v :vert sfind<Space>
" juggling with buffers
nnoremap ,b :buffer <C-z>
" juggling with tags
nnoremap ,t :tjump /
nnoremap ,p :ptjump /
Beside all those custom mappings, macros, Ex commands, motions, text-object and in general the whole "grammar" that ties everything are killer features.