-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sander Marechal
committed
Jan 31, 2013
0 parents
commit cd68b58
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |