Thursday, December 20, 2018

Re: operator's "count" doesn't work

On Thu, Dec 20, 2018 at 7:35 AM Vladimir Stenbock <vstenbock@gmail.com> wrote:
>
>
> I want to delete N substrings inside double quotes
>
> word1 word2 "substring1" word3 "substring2" word4 word5 "substring3"
>
> but :norm 3da" doesn't work

Under |aquote| it is said (/in fine/) "A count is currently not used."
so this is expected.

You might try the following (untested)

function DelString(...)
if a:0 == 0
let i = 1
elseif type(a:1) == type(0)
let i = a:1
else
echoerr ":DSt / DelString() argument should be a
Number or omitted"
endif
let @/ = '"\ze\B' |" caution: operand starts with
single then double quotes
while i > 0
normal nda"
let i -= 1
endwhile
endfunction
command -nargs=? -bar DSt call DelString(<args>)

If I didn't goof, then :DSt alone should delete one double-quoted
string, or :DSt followed by a count should delete that number of
double-quoted strings anywhere in the file starting at the earliest on
the character immediately following the cursor. (Caution: if there are
fewer than that number of strings after the cursor, and 'wrapscan' is
on (default) then more strings will be deleted starting at the top of
the file.) The :let @/ line checks that the opening quote is not
followed by a space; change the pattern if you want different
behaviour. Special case: :Dst 0 or :Dst with a negative argument
should do nothing; a non-numeric argument should throw an error.

Best regards,
Tony.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: