Skip to content

Instantly share code, notes, and snippets.

@remarkablemark
Created March 19, 2018 15:03
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save remarkablemark/23669b32afad86d32b1084f6abc4a9b5 to your computer and use it in GitHub Desktop.
Save remarkablemark/23669b32afad86d32b1084f6abc4a9b5 to your computer and use it in GitHub Desktop.
How to install vim-prettier with Vim Vundle

vim-prettier

Open vimrc:

vim ~/.vim/vimrc

Add Vundle plugin to vimrc:

Plugin 'prettier/vim-prettier'

Save and install within Vim:

:PluginInstall

Then either install prettier globally:

# with npm
npm install -g prettier

# or with yarn
yarn global add prettier

Or within the local bundle repository itself:

cd ~/.vim/bundle/vim-prettier

# with npm
npm install

# or with yarn
yarn

Now you can run prettier in Vim:

:Prettier

Vim 8+:

:PrettierAsync

Make sure to overwrite default prettier configuration. E.g.,

let g:prettier#config#bracket_spacing = 'true'
let g:prettier#config#jsx_bracket_same_line = 'false'

Running before saving in Vim:

let g:prettier#autoformat = 0
autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue PrettierAsync
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment