Skip to content

Commit

Permalink
format: only add extra empty line below, not above
Browse files Browse the repository at this point in the history
  • Loading branch information
sunaku committed Jul 8, 2020
1 parent 865c13d commit a74a062
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions plugin/format.vim
Expand Up @@ -192,48 +192,45 @@ endfunction
function! Format_section_comment_lines() abort
let cursor = winsaveview()

" open a new comment line below (and another blank line below it)
normal! 2o
normal! cc
" open a new comment line above
normal! O

" return to starting position
normal! 2k
normal! j

" open a new comment line above (and another blank line above it)
normal! 2O
normal! kcc
" open a new comment line below and another blank line below that
normal! 2o
normal! cc

" return to starting position
call winrestview(cursor)
normal! 2j
normal! j
endfunction

" format line as comment section, surrounding with blank comment lines
function! Format_section_minus_signs() abort
let cursor = winsaveview()

" open a new comment line below (and another blank line below it)
normal! 2o
normal! cc
" open a new comment line above
normal! O

" add minus sign separators on the newly opened comment line below
normal! k
" add minus sign separators on the newly opened comment line above
call Format_separator_minus_sign()

" return to starting position
normal! k
normal! j

" open a new comment line above (and another blank line above it)
normal! 2O
normal! kcc
" open a new comment line below and another blank line below that
normal! 2o
normal! cc

" add minus sign separators on the newly opened comment line above
normal! j
" add minus sign separators on the newly opened comment line below
normal! k
call Format_separator_minus_sign()

" return to starting position
call winrestview(cursor)
normal! 2j
normal! j
endfunction

" insert or update section separator at end of current line
Expand Down

0 comments on commit a74a062

Please sign in to comment.