Skip to content

Commit f43a5cd

Browse files
authored
Implement csf and dsf
csf = Change surround function to specified one. dsf = Remove surrounding function. The deleted function name is stored in the unnamed register. Closes tpope#157.
1 parent f51a26d commit f43a5cd

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

plugin/surround.vim

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,8 @@ function! s:dosurround(...) " {{{1
406406
exe 'norm! l'
407407
endif
408408
exe 'norm! dt'.char
409+
elseif char == 'f'
410+
exe 'norm! d'.strcount.'i('
409411
else
410412
exe 'norm! d'.strcount.'i'.char
411413
endif
@@ -436,7 +438,14 @@ function! s:dosurround(...) " {{{1
436438
else
437439
" One character backwards
438440
call search('\m.', 'bW')
439-
exe "norm! da".char
441+
if char == "f"
442+
exe "norm! da("
443+
exe "norm! bdw"
444+
" will put the deleted function name into the unnamed reg
445+
let original = getreg('"')
446+
else
447+
exe "norm! da".char
448+
endif
440449
endif
441450
let removed = getreg('"')
442451
let rem2 = substitute(removed,'\n.*','','')

0 commit comments

Comments
 (0)