vim4js


Ⅰ. 插件描述

Vim goodies for Javascript

Ⅱ. 基本信息

创建日期:  2010-06-29
使用用户:  1
Github星:  4
插件作者:  David Wilhelm

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'bigfish/vim4js'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'bigfish/vim4js'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'bigfish/vim4js'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/bigfish/vim4js

Ⅳ. 文档说明

# Vim4JS -- Vim for Javascript

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

Requirements

nodelint

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

sudo npm install -g nodelint@0.5.2

vim-nodelint

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:

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.

添加新评论