So, I just learned that gf
exists. If your cursor is over a path in vim, and you type gf, it'll open that file/dir in a new buffer. You can also open in a new window/tab as detailed here.
In node, it'd be great if you could jump to a required
file, huh? Trouble is, typically you don't put the .js
on your require('./path/to/a/js/file')
. No matter, vim has your back, just add set suffixesadd+=.js
to your .vimrc and vim will try adding .js and see if it can find that file instead.
If you do a lot of spelunking in node_modules, it'd be great if you could jump to the directory of a required npm module too, right? A la, require('my-awesome-module')
. Well, you can add set path+=$PWD/node_modules
to your .vimrc too, and vim will add node_modules to the path, and jump to it's directory in node_modules (caveat: you must have opened vim from your project root for this too work).
For your cmd+c convenience:
set suffixesadd+=.js
set path+=$PWD/node_modules
✨