vim Tips and tricks to boost productivity Copy, move or delete found line


A lot of users find themselves in a situation where they just want to copy, move or delete a line quickly and return to where they were.

Usually, if you'd want to move a line which contains the word lot below the current line you'd type something like:


But to boost productivity you can use this shortcut in these cases:

" It's recommended to turn on incremental search when doing so
set incsearch

" copy the found line
cnoremap $t <CR>:t''<CR>
" move the found line
cnoremap $m <CR>:m''<CR>
" delete the found line
cnoremap $d <CR>:d<CR>``

So a search like this:


would move the line which contains lot below the line your cursor was on when you started the search.