Vim Tips Thread

I wonder if there is a way to ignore the node_modules directory.

It looks like I can do something like this, but I’ll have to figure out how vim is running the command.

$ ctags -R --exclude=.git --exclude=node_modules --exclude=test

I learned a Vim trick for inserting repeated characters in insert mode.

ctrl+o runs a normal mode command from insert mode. For example, to add a line of 80 slashes, you can do:

ctrl+o 80i/ESC

So to get a comment block like this (except 80 characters wide), use that above command to make the first line and then hit yypO:

/////////////////////////////////////////////////////////
// █
/////////////////////////////////////////////////////////

Then type your comment.

Reference for the commands used:

  • yy – copies the current line
  • p – pastes what you just copied
  • shift+o – opens a line in insert mode

Also, I usually open new Vim tabs with :tabnew, but in these videos I saw the instructor open a new tab with :tabe. So I looked at the help file (:h tabe) and there is a lot of interesting stuff in there. You can tell Vim exactly where you want the new tab to open (like :3tabe), or what kind of command to run in the new tab.

Just press ESC and type this for the docs:

:h tabe