Skip to content

Commit

Permalink
Implement csf and dsf
Browse files Browse the repository at this point in the history
csf = Change surround function to specified one.
dsf = Remove surrounding function.

The deleted function name is stored in the unnamed register.
Closes tpope#157.
  • Loading branch information
xbe committed Sep 5, 2020
1 parent f51a26d commit f43a5cd
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion plugin/surround.vim
Expand Up @@ -406,6 +406,8 @@ function! s:dosurround(...) " {{{1
exe 'norm! l'
endif
exe 'norm! dt'.char
elseif char == 'f'
exe 'norm! d'.strcount.'i('
else
exe 'norm! d'.strcount.'i'.char
endif
Expand Down Expand Up @@ -436,7 +438,14 @@ function! s:dosurround(...) " {{{1
else
" One character backwards
call search('\m.', 'bW')
exe "norm! da".char
if char == "f"
exe "norm! da("
exe "norm! bdw"
" will put the deleted function name into the unnamed reg
let original = getreg('"')
else
exe "norm! da".char
endif
endif
let removed = getreg('"')
let rem2 = substitute(removed,'\n.*','','')
Expand Down

0 comments on commit f43a5cd

Please sign in to comment.