Skip to content

Commit 108994d

Browse files
committed
vim: more line manipulation
1 parent a8e9180 commit 108994d

File tree

1 file changed

+33
-9
lines changed

1 file changed

+33
-9
lines changed

nvim/init.vim

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
" nvim file: ~/.config/nvim/init.vim
2-
" Last Change: 2018 mar 17 18:40
2+
" Last Change: 2018 mar 17 20:36
33
" vim: ff=unix ai et ts=4
44
" Author: Sérgio Luiz Araújo Silva
55
" Reference: http://sergioaraujo.pbworks.com/w/page/15864094/vimrc
@@ -723,13 +723,6 @@ nnoremap <F3> :CountWord<CR>
723723
" nnoremap <silent> <Leader>o :<C-u>call append(line("."), repeat([""], v:count1))<CR>
724724
" nnoremap <silent> <Leader>O :<C-u>call append(line(".")-1, repeat([""], v:count1))<CR>
725725

726-
" https://vi.stackexchange.com/a/7278/7339
727-
" https://superuser.com/a/147842/45032
728-
" Insert new line above and below in normal mode
729-
" unimpaired [<space ]<space>
730-
nnoremap <CR> :call append(line('.'), '')<CR>
731-
nnoremap <A-CR> :call append(line('.')-1, '')<CR>
732-
733726
" Autocmd Rules **********************************
734727

735728
"colorscheme ayu
@@ -939,13 +932,44 @@ nnoremap <C-k> _D
939932
" https://vi.stackexchange.com/a/8368/7339
940933
function! DeleteAbove()
941934
if getline(".") =~ "^$"
942-
exec 'normal! kdd'
935+
exec 'normal! kdd0'
943936
else
944937
exec 'normal! d0dgk"-Pl'
945938
endif
946939
endfunction
947940
nnoremap <Leader>k :call DeleteAbove()<CR>
948941
942+
" https://vi.stackexchange.com/a/4171/7339
943+
"function! DeleteOver()
944+
" let save_cursor = getpos(".")
945+
" normal k
946+
" normal dd
947+
" call setpos(".", save_cursor)
948+
" normal k
949+
"endfunction
950+
"nnoremap <Leader>k :call DeleteOver()<CR>
951+
952+
function! DeleteUnder()
953+
let save_cursor = getpos(".")
954+
normal j
955+
normal dd
956+
call setpos(".", save_cursor)
957+
endfunction
958+
nnoremap <Backspace> :call DeleteUnder()<CR>
959+
960+
" https://vi.stackexchange.com/a/7278/7339
961+
" https://superuser.com/a/147842/45032
962+
" Insert new line above and below in normal mode
963+
" unimpaired [<space ]<space>
964+
nnoremap <CR> :call append(line('.'), '')<CR>
965+
nnoremap <A-CR> :call append(line('.')-1, '')<CR>
966+
967+
" Here we have some shortcuts (above)
968+
" <CR> ............... add new line below in normal mode
969+
" <A-CR> ............. add new line above in normal mode
970+
" <Leader>k .......... removes line above in normal mode
971+
" <Backspace> ........ removes line below in normal mode
972+
949973
" Make Ctrl-e jump to the end of the current line in the
950974
" insert mode. This is handy when you are in the middle of
951975
" a line and would like to go to its end without switching

0 commit comments

Comments
 (0)