Optimizing your workflow

Everyone's workflow is unique, and no two people use Vim in exactly the same way. It's useful to find ways to compliment your style by enhancing and optimizing the way you do things in Vim.

Find yourself using a particular command a lot? Create a custom key binding!

For example, I use the CtrlP plugin quite a lot (both for navigating the file tree and the buffer list), and I have the following custom mappings:

nnoremap <leader>p :CtrlP <cr>
nnoremap <leader>t :CtrlPTag <cr>

I also often find myself running the :Ack command (provided by the ack-vim plugin) on a word under cursor, so I have the following in my .vimrc:

nnoremap <leader>a :Ack! <c-r><c-w><cr>

The <c-r> and <c-w> inserts the word under cursor into the command line. Use :grep for a similar purpose? Not a problem:

nnoremap <leader>g :grep <c-r><c-w> */**<cr>

Accidentally find yourself hitting ; instead of : to enter command-line mode? Remap it:

nnoremap ; :
vnoremap ; :

Whenever you catch yourself doing something a lot, take a moment to add a relevant key binding to make your life easier.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.137.218