run esformatter from inside vim (automatically formats JavaScript source code)
Vim script
Switch branches/tags
Nothing to show
Clone or download
Latest commit 1e1fd53 Oct 16, 2015
Permalink
Failed to load latest commit information.
doc Update esformatter.txt Feb 27, 2015
plugin change date Jun 26, 2015
LICENSE.txt v1.0.0 Feb 27, 2015
README.md Update README.md Oct 16, 2015

README.md

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.

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>

License

released under the wtfpl license