You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I currently use this bit of vimscript I wrote in my vimrc file to toggle vim-prettier autoformat on/off:
""" Toggle vim-prettier auto formatting with <Leader>pr
nnoremap <leader>pr :call TogglePrettier()<cr>
" enable autoformatting by default
let g:prettier#autoformat=0
autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue,*.yaml,*.html PrettierAsync
function! TogglePrettier()
if g:prettier#autoformat
let g:prettier#autoformat=0
autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue,*.yaml,*.html PrettierAsync
else
let g:prettier#autoformat=1
autocmd! BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue,*.yaml,*.html call clearmatches()
endif
endfunction
because I like to keep autoformat on by default but once in a while I like to turn it off temporarily, e.g., if i don't want a json string to be multiple lines, etc. This allows you to still type <Leader>p, by making a new map called <Leader>pr but i don't care if you choose another mapping or way of doing this all together.
I can see it being difficult to get all the variations of autoformating and different file extensions working so maybe just a documentation of how to do it would be enough. Love the plugin, thanks!
The text was updated successfully, but these errors were encountered:
I currently use this bit of vimscript I wrote in my vimrc file to toggle vim-prettier autoformat on/off:
because I like to keep autoformat on by default but once in a while I like to turn it off temporarily, e.g., if i don't want a json string to be multiple lines, etc. This allows you to still type
<Leader>p
, by making a new map called<Leader>pr
but i don't care if you choose another mapping or way of doing this all together.I can see it being difficult to get all the variations of autoformating and different file extensions working so maybe just a documentation of how to do it would be enough. Love the plugin, thanks!
The text was updated successfully, but these errors were encountered: