A collection of plugins, and settings for effective Javascript editing in Vim.
Installation (after Node.js, and NPM have been installed):
sudo npm install -g [email protected]
This is a separate vim compiler plugin I wrote. I recommend you use pathogen to install this into your bundle/ directory. Or you can install it manually.
Included in after/ftplugin/javascript.vim
.
Sets tabwidth to 4, and always expands tabs to spaces.
Also adds a couple of keymaps (in .js files only):
- Shift + Enter --> addds semicolon to end of line
- Ctrl + Shift + Enter --> adds a comma at the end of the line
Also sets the compiler to 'nodelint' (uses the vim-nodelint plugin)
Includes this javascript syntax, with a minor tweak to allow folding on {} and [] blocks, as well as functions. use 'zc' to close, and 'zo' to open folds.
Includes the web-indent plugin.
This allows you to use the builtin indent commands (essentially '=' in command mode, combined with a motion, eg. 'gg=G' for the whole file, or just select some text in visual mode and hit '=').
The filetype settings apply the same settings to JSON as Javascript, meaning that you can
- run jslint on the JSON on save
- fold on {}, []
- do indenting using =
Note that the jslint is JSON specific: it knows the content is JSON and will enforce JSON-isms, like requiring double-quoted keys.
Not included, but recommended, are my customized versions of exuberant-ctags, and taglist:
- ctags_actionscript
- js-taglist
To install, clone the ctags_actionscript repo somewhere (not in your vim bundle dir), cd into it, and do:
./configure
make
sudo make install
Then clone the js-taglist repo into your vim bundle dir (if using pathogen), or copy the plugin.
In my .vimrc I have
nnoremap <silent><A-t> :TlistToggle<CR>
Which will open/close the taglist.