Tweaked insert mode indent rules

This commit is contained in:
Tim Pope 2007-07-31 14:20:47 +00:00
parent 714e9b8a61
commit 18967e9fcb

View File

@ -353,6 +353,13 @@ function! s:insert(...) " {{{1
let reg_save = @@ let reg_save = @@
call setreg('"',"\r",'v') call setreg('"',"\r",'v')
call s:wrapreg('"',char,linemode) call s:wrapreg('"',char,linemode)
" If line mode is used and the surrounding consists solely of a suffix,
" remove the initial newline. This fits a use case of mine but is a
" little inconsistent. Is there anyone that would prefer the simpler
" behavior of just inserting the newline?
if linemode && matchstr(getreg('"'),'^\n\s*\zs.*') == 0
call setreg('"',matchstr(getreg('"'),'^\n\s*\zs.*'),getregtype('"'))
endif
" This can be used to append a placeholder to the end " This can be used to append a placeholder to the end
if exists("g:surround_insert_tail") if exists("g:surround_insert_tail")
call setreg('"',g:surround_insert_tail,"a".getregtype('"')) call setreg('"',g:surround_insert_tail,"a".getregtype('"'))
@ -365,7 +372,7 @@ function! s:insert(...) " {{{1
else else
norm! ""P norm! ""P
endif endif
if @@ =~ '\r.*\n' if linemode
call s:reindent() call s:reindent()
endif endif
norm! `] norm! `]