Skip to content

Commit a9b8f32

Browse files
committed
vim: better DeleteLineAbove()
1 parent f5e0b08 commit a9b8f32

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

nvim/init.vim

Lines changed: 10 additions & 8 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 19 17:50
2+
" Last Change: 2018 mar 22 16:49
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
@@ -932,14 +932,16 @@ nnoremap <C-k> _D
932932
933933
" Delete line above without moving the cursor
934934
" https://vi.stackexchange.com/a/8368/7339
935-
function! DeleteAbove()
936-
if getline(".") =~ "^$"
937-
exec 'normal! kdd0'
938-
else
939-
exec 'normal! d0dgk"-Pl'
940-
endif
935+
function! DeleteLineAbove()
936+
if line('.') == 1
937+
echom "You are at the first line!"
938+
return
939+
endif
940+
let l:colsave = col(".")
941+
exec "normal! kdd"
942+
call cursor(line("."), l:colsave)
941943
endfunction
942-
nnoremap <Leader>k :call DeleteAbove()<CR>
944+
nnoremap <Leader>k :call DeleteLineAbove()<CR>
943945
944946
" https://vi.stackexchange.com/a/4171/7339
945947
"function! DeleteOver()

vim/wiki/dicasvim.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# dicasvim.md Intro - Last Change: 2018 mar 22 08:44
1+
# dicasvim.md Intro - Last Change: 2018 mar 22 08:49
22
vim: set ts=4 et:
33

44
+ http://yannesposito.com/Scratch/en/blog/Learn-Vim-Progressively/#navigation
@@ -1185,6 +1185,7 @@ there a way to do this in one fail swoop?
11851185

11861186
:%s/.*pattern.*/\=@y
11871187
:g/pattern/normal! V"yp
1188+
:g/pattern/exe "normal! S\<c-r>y"
11881189

11891190
or the following which won't change the default register:
11901191

vim/wiki/emacs.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ the end of the expression and press
7878
‘C-a C-k C-y’ kills and yanks back the line without newline if kill-whole-line is nil, or including the newline otherwise.
7979
‘C-S-backspace C-y’ Kills an entire line at once (kill-whole-line) and yanks it back.
8080

81+
# Creating new buffer
82+
83+
C-x b
84+
8185
# Install new packages
8286

8387
;; ================== add melpa repo ==================================

vim/wiki/phrases.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ Estas relações "distorcidas|assimétricas" geram o efeito político contrário
1313
She never stops talking about dieting. She’s got a real bee in her bonnet about it. (Ela nunca para de falar sobre dietas. Ela tem uma obsessão nisso.)
1414

1515
He’s got a bee in his bonnet about factory farming. (Ele é obcecado por pecuária industrial.)
16+
17+
Unlocking a wealth of answers about human beings and their potentials, he did indeed resolve the long-standing riddle of the mind.
18+
Desbloqueando uma riqueza de respostas sobre os seres humanos e seus potenciais, ele realmente resolveu o antigo enigma da mente.

0 commit comments

Comments
 (0)