Vim tips and tricks that I find useful

Published on

shift + j (J) to combine lines

Use shift and j to combine lines

If you had these lines:

aaaaaaaaa
bbbbbbbbb

And your cursor was on the first line and you pressed shift and j, then it would end up like:

aaaaaaaaa bbbbbbbbb

Note: for Jet Brains Idea VIM (for phpstorm/webstorm), turn on set ideajoin in your .ideavimrc.

Jetbrains specific (PHPStorm or WebStorm)

Edit .ideavimrc from your IDE

  • In the bottom right there is a V logo (for the ideaVIM plugin) - click it, and in that menu is an option to edit the .ideavimrc file.

Change mode in modals

Sometimes ideaVIM will open a modal and you'll be in the wrong vim mode. Pressing escape would close the modal. So instead press shift + ] which does the same thing as escape.

NERDtree key bindings for the project/file explorer tab:

.ideavimrc
Plug 'preservim/nerdtree'
set NERDTree

I have it set with cmd + 1 to open the file/project browser.

From there I can use:

  • j/k to move down or up.
  • Press o to open selected file
  • Press m to open menu on selected file/dir
  • Press go to open selected file, but keep cursor in the file list (useful if you want to open a few files at once)
  • Press s to open selected file in a split vsplit. gs to open it in new vsplit but keep cursor in file list.
  • Press p to go to the parent directory.
  • Press x to close the current dir
  • Press P to go to top level dir
  • Press / and then search for a file name