Skip to content

Latest commit

 

History

History
53 lines (35 loc) · 1.49 KB

README.md

File metadata and controls

53 lines (35 loc) · 1.49 KB

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>

To enable auto-format on save:

let g:esformatter_autosave = 1

License

released under the wtfpl license