Skip to content

Commit 7458012

Browse files
committed
add g:clang_format#auto_format
1 parent b3ad52e commit 7458012

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

plugin/clang_format.vim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,11 @@ command! -range=% -nargs=0 ClangFormat call clang_format#replace(<line1>, <line2
1212

1313
command! -range=% -nargs=0 ClangFormatEchoFormattedCode echo clang_format#format(<line1>, <line2>)
1414

15+
if 1 || get(g:, 'clang_format#auto_format', 0)
16+
augroup plugin-clang-format-auto-format
17+
autocmd!
18+
autocmd BufWritePre * if &ft ==# 'cpp' | call clang_format#replace(1, line('$')) | endif
19+
augroup END
20+
endif
21+
1522
let g:loaded_clang_format = 1

0 commit comments

Comments
 (0)