Tools to make Vim superb for developing with Node.js.
It's the Node equivalent of Rails.vim (vimscript #1567) and Rake.vim (vimscript #3669).
This is just the first release to get the nodes rolling. If you've collected great helpers and shortcuts that help you work with Node, please share them via email, Twitter or GitHub issues so we could incorporate them here, too! Thanks!
gf
on paths or requires to open the same file Node.js would.gf
on require(".")
to open ./index.js
gf
on require("./dir")
to open ./dir/index.js
gf
on require("./foo")
to open foo.js
.gf
on require("./package")
and have it open package.json.gf
on require("module")
to open the module's main file (parsed for you from package.json
).gf
on require("module/lib/utils")
and open files inside the module.#!
).[I
etc. to look for a keyword in required files (Sets Vim's &include
).:Nedit
to quickly edit any module, file in a module or your project file.:Nopen
to quickly edit any module and lcd
to its directory.Expect more to come soon and feel free to let me know what you're after!
PS. Node.vim is absolutely intended to work on Windows, but not yet tested there at all. If you could help, try it out and report issues, I'd be grateful!
The easiest and most modular way is to download this to ~/.vim/bundle
:
mkdir -p ~/.vim/bundle/node
Using Git:
git clone https://github.com/moll/vim-node.git ~/.vim/bundle/node
Using Wget:
wget https://github.com/moll/vim-node/archive/master.tar.gz -O- | tar -xf- --strip-components 1 -C ~/.vim/bundle/node
Then prepend that directory to Vim's &runtimepath
(or use Pathogen):
:set runtimepath^=~/.vim/bundle/node
Or use Vundle:
:BundleInstall moll/vim-node
Open any JavaScript file inside a Node project and you're all set.
gf
inside require("...")
to jump to source and module files.[I
on any keyword to look for it in the current and required files.:Nedit module_name
to edit the main file of a module.:Nedit module_name/lib/foo
to edit its lib/foo.js
file.:Nedit .
to edit your Node projects main (usually index.js
) file.Use the Node
autocommand. For example:
autocmd User Node if &filetype == "javascript" | setlocal expandtab | endif
<C-w>f
to open the file under the cursor in a new vertical split?<C-w>f
by default opens it in a horizontal split. To have it open vertically, drop this in your vimrc
:
autocmd User Node
\ if &filetype == "javascript" |
\ nmap <buffer> <C-w>f <Plug>NodeVSplitGotoFile |
\ nmap <buffer> <C-w><C-f> <Plug>NodeVSplitGotoFile |
\ endif
Open Vim in the directory of a Node.js project and use :Nedit
with the name of the core module:
:Nedit http
This downloads a single file from the Node.js repository for your Node version through https://rawgit.com. If you'd like to change the base URL, set g:node_repository_url
:
let node_repository_url = "https://example.com/nodejs/node"
Node.vim is released under a Lesser GNU Affero General Public License, which in summary means:
For more convoluted language, see the LICENSE
file.
Andri Möll authored this in SublemacslipseMate++.
Monday Calendar supported the engineering work.
If you find Node.vim needs improving or you've got a question, please don't hesitate to email me anytime at andri@dot.ee, tweet at @theml or create an issue online.