@@ -186,7 +186,7 @@ function! s:detect_style_file()
186186endfunction
187187
188188function ! clang_format#format (line1, line2)
189- let args = printf ( ' -lines=%d:%d ' , a: line1 , a: line2 )
189+ let args = " "
190190 if ! (g: clang_format #detect_style_file && s: detect_style_file ())
191191 let args .= printf (' -style=%s ' , s: make_style_options ())
192192 else
@@ -198,7 +198,7 @@ function! clang_format#format(line1, line2)
198198 endif
199199 let args .= g: clang_format #extra_args
200200 let clang_format = printf (' %s %s --' , s: shellescape (g: clang_format #command ), args )
201- return s: system (clang_format, join (getline (1 , ' $ ' ), " \n " ))
201+ return s: system (clang_format, join (getline (a: line1 , a: line2 ), " \n " ))
202202endfunction
203203" }}}
204204
@@ -216,8 +216,12 @@ function! clang_format#replace(line1, line2)
216216 try
217217 let formatted = clang_format#format (a: line1 , a: line2 )
218218 if s: success (formatted)
219+ let indent = indent (a: line1 ) / shiftwidth ()
220+ silent exe a: line1 .' ,' a: line2 .' delete _'
221+
219222 call setreg (' g' , formatted, ' V' )
220- silent keepjumps normal ! ggVG" gp
223+ silent put ! g
224+ silent exe " '[,']" .repeat (' >' , indent )
221225 else
222226 call s: error_message (formatted)
223227 endif
0 commit comments