From f43a5cdecc279bb3bc87ed33365ce74055a241c0 Mon Sep 17 00:00:00 2001 From: xbe Date: Sat, 5 Sep 2020 04:43:36 -0700 Subject: [PATCH] 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 #157. --- plugin/surround.vim | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/plugin/surround.vim b/plugin/surround.vim index 303bd2b..4fa1f1c 100644 --- a/plugin/surround.vim +++ b/plugin/surround.vim @@ -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 @@ -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.*','','')