Lately I was reading an old book about Vim. And I found a bunch of new tricks I didn’t know!
- :sbuffer N: split the screen horizontally and open buffer N. No need to
ctrl+W, S then :bN anymore! You can split vertically with
:vert sbuffer N
(or the shortcut:vert sbN
) - If you have splitted your screen to much and you feel that your life is a mess, try
CTRL+w, o
to keep current window only. - If you have splitted your screen to much and you feel that your life is a
mess, try
:qall
to quit all at once. I remapped it to q in command mode in my .vimrc this week. - I used to be very limited in visual mode. Precisely, I almost never use the
block visual selection. I’m wrong! You can select a block and do
I<insert your text><esc>
to insert before the block in every seleced line.A<insert your text><esc>
to insert after the block. - Speaking about visual block, you can select the whole lines form the block selection by hitting $. It could be useful.
- gd in normal mode stands for “go to declaration”. It may work for the language you need and can help you on legacy code with oversized functions / methods.
- CTRL-x, CTRL-f: as you may know, Vim has several types of completions that are extremely useful. I didn’t know this particular one: it completes using file names in current workin directory (cwd). By the way, if you want to change Vim cwd do like you do in the shell with command
:cd <directory>
. - CTRL+l redraws the buffers. It’s quicker than
:redraw
command.
I’m glad to be still learning with Vim after all these year. That’s a reason why I like this editor so much. Have a nice week end folks!