Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Sander Marechal committed Jan 31, 2013
0 parents commit cd68b58
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
EmptyLines
==========

A quick VIM plugin for adding/removing empty lines around code.
Install it using Vundle. Example configuration:

nnoremap <silent> <Up> :call DelEmptyLineAbove()<CR>
nnoremap <silent> <Down> :call AddEmptyLineAbove()<CR>
nnoremap <silent> <C-Up> :call DelEmptyLineBelow()<CR>
nnoremap <silent> <C-Down> :call AddEmptyLineBelow()<CR>
40 changes: 40 additions & 0 deletions plugin/emptyLines.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
function! DelEmptyLineAbove()
if line(".") == 1
return
endif
let l:line = getline(line(".") - 1)
if l:line =~ '^\s*$'
let l:colsave = col(".")
.-1d
silent normal! <C-y>
call cursor(line("."), l:colsave)
endif
endfunction

function! AddEmptyLineAbove()
let l:scrolloffsave = &scrolloff
" Avoid jerky scrolling with ^E at top of window
set scrolloff=0
call append(line(".") - 1, "")
if winline() != winheight(0)
silent normal! <C-e>
endif
let &scrolloff = l:scrolloffsave
endfunction

function! DelEmptyLineBelow()
if line(".") == line("$")
return
endif
let l:line = getline(line(".") + 1)
if l:line =~ '^\s*$'
let l:colsave = col(".")
.+1d
''
call cursor(line("."), l:colsave)
endif
endfunction

function! AddEmptyLineBelow()
call append(line("."), "")
endfunction

0 comments on commit cd68b58

Please sign in to comment.