Open niming175 opened 3 years ago
Try checking your config file for the g:prettier#autoformat
variable. If you see:
let g:prettier#autoformat = 1
Try to either set this value to 0, or remove the line entirely (vim-prettier defaults the value to 0
).
I was brought here on an unrelated note. I noticed that my cursor moves to the front of the line (functional equivalent of ^
) whenever I save. It was getting annoying that I was losing my cursor position. This only seems to be occurring on my linux computer. My mac appears fine.
If you're looking for a "fix", you can remove the augroup Prettier.
diff --git a/plugin/prettier.vim b/plugin/prettier.vim
index 3326f26..64eeef3 100644
--- a/plugin/prettier.vim
+++ b/plugin/prettier.vim
@@ -172,7 +172,3 @@ nnoremap <silent> <Plug>(PrettierCli) :PrettierCli<CR>
nnoremap <silent> <Plug>(PrettierCliVersion) :PrettierCliVersion<CR>
nnoremap <silent> <Plug>(PrettierCliPath) :PrettierCliPath<CR>
-augroup Prettier
- autocmd!
- autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.gql,*.markdown,*.md,*.mdown,*.mkd,*.mkdn,*.mdx,*.vue,*.yml,*.yaml,*.html,*.php,*.rb,*.ruby,*.xml noautocmd | call prettier#Autoformat()
-augroup end
Note that this will break autoformat functionality when you set let g:prettier#autoformat = 1
. I personally only use :Prettier
and do not rely on any auto formatting.
How to cancel the auto format when i save? when i save the code , i didn't want it to auto format; How am i to set the config