Open vimrc:
vim ~/.vim/vimrcAdd Vundle plugin to vimrc:
Plugin 'prettier/vim-prettier'Save and install within Vim:
:PluginInstallThen either install prettier globally:
# with npm
npm install -g prettier
# or with yarn
yarn global add prettierOr within the local bundle repository itself:
cd ~/.vim/bundle/vim-prettier
# with npm
npm install
# or with yarn
yarnNow you can run prettier in Vim:
:PrettierVim 8+:
:PrettierAsyncMake 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