Skip to content

Commit

Permalink
plugin: do not <END> when breaking a line in the middle
Browse files Browse the repository at this point in the history
  • Loading branch information
intelfx committed Aug 1, 2024
1 parent 013d754 commit 1215857
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion plugin/smarttabs.vim
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,14 @@ if ! exists('g:ctab_disable_checkalign') || g:ctab_disable_checkalign==0
endif
return "\<CR>"
else
return "\<CR>\<c-r>=".s:SID().'CheckAlign(line(''.''))'."\<CR>\<END>"
let l:cursoradj = ""
let l:restofline = getline('.')[col('.') - 1:]
if len(l:restofline) && l:restofline !~ '^\s*$'
" adjust cursor position (go to first nonblank) only if the line was
" broken in the middle, i.e. if we have text after cursor
let l:cursoradj = "\<ESC>:normal!^\<CR>:startinsert\<CR>"
endif
return "\<CR>\<c-r>=".s:SID().'CheckAlign(line(''.''))'."\<CR>\<END>" . l:cursoradj
endif
endfun

Expand Down

0 comments on commit 1215857

Please sign in to comment.