Skip to content

bigfish/vim4js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vim4JS -- Vim for Javascript

A collection of plugins, and settings for effective Javascript editing in Vim.

Requirements

Installation (after Node.js, and NPM have been installed):

sudo npm install -g nodelint@0.5.2

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.

Features

Filetype settings

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)

Better Javascript Syntax

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.

Indentation

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 '=').

JSON Support

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.

JS-Taglist (optional addon)

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.

About

Vim goodies for Javascript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published