vim-esformatter


Ⅰ. 插件描述

run esformatter from inside vim (automatically formats JavaScript source code)

Ⅱ. 基本信息

创建日期:  2015-02-27
使用用户:  65
Github星:  35
插件作者:  Miller Medeiros

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

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

Ⅳ. 文档说明

# vim-esformatter

makes it easier to execute esformatter
inside vim.

it's better than executing a simple
:%!esformatter on
normal mode because it avoids replacing the buffer content if the script
detected any errors, it restores the cursor position and sets the working
directory to match the file (which changes the way esformatter looks for config
files).

it was inspired by [nisaacson esformatter
plugin](https://gist.github.com/nisaacson/6939960).

Installation

You will need the esformatter binary available in your path to run the command

npm install -g esformatter

After that you can use Vundle,
pathogen.vim or manually copy the
plugin/esformatter.vim file into your ~/.vim/plugin folder to install it.

Usage

To format the whole file simple call :Esformatter while on normal mode.

To format just one block of code select it on visual mode and execute
:'<,'>EsformatterVisual.

To make it easier you can create a mapping on your .vimrc file like:

" will run esformatter after pressing <leader> followed by the 'e' and 's' keys
nnoremap <silent> <leader>es :Esformatter<CR>
vnoremap <silent> <leader>es :EsformatterVisual<CR>

To enable auto-format on save:

let g:esformatter_autosave = 1

License

released under the wtfpl license

添加新评论