vim-autoformat / vim-autoformat

Provide easy code formatting in Vim by integrating existing code formatters.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failed to format part of the code with clang-format

onlycalm opened this issue · comments

commented

The configuration of .vimrc is as follows:

"vim-autoformat/vim-autoformat
let g:formatdef_clangformat_google = '"clang-format -style google -"'
let g:formatters_c = ['clangformat_google']
let g:autoformat_autoindent = 0
let g:autoformat_retab = 0
let g:autoformat_verbosemode = 1
let g:autoformat_remove_trailing_spaces = 1

Methods of reproducing problems:

  1. Select a code block in visual mode and execute instructions :Autoformat .
  2. Execute Instructions AutoformatLine .

It will format the entire C file, rather than just part of the code block.

commented

Look at the default definition to see how to pass the range arguments to clang.