How to combine the command df" and df[

28 views
Skip to first unread message

李哲

unread,
Jun 4, 2016, 12:52:38 AM6/4/16
to vim_use
I usually use the command `dt"` and `dt[` to delete the content from the current position to the mark [ or ".

Is there a way that use the commannd `dtt`(for example) to combine the two `dt[` and `dt"` command?

for example , `$` mark the current position of the curor.
1. "aaaa$bbbb"[cccccddddd] ; command dtt delete bbbb
2. "aaaabbbb"[ccccc$ddddd] ; command dtt delete ddddd
3. [ccccc"aaaa$bbbb"ddddd] ; command dtt delete bbbb, find the " or ] which is closer to the current curor

I think it need a custum function to make it.
And the problem for me now is now to locate the closer " or ], and then delete to the mark.

Shlomi Fish

unread,
Jun 4, 2016, 3:53:59 AM6/4/16
to vim...@googlegroups.com
Hi imlegendlzz,
Perhaps try visual selection («:help v») or the «:help /» command doing
something like /[\w\[] or a combination of both.

Regards,

Shlomi Fish

--
-----------------------------------------------------------------
Shlomi Fish

God is Chuck Norris, for extremely large values of God.

Please reply to list if it's a mailing list post

Christian Brabandt

unread,
Jun 4, 2016, 3:59:38 AM6/4/16
to vim_use

On Fr, 03 Jun 2016, 李哲 wrote:

> I usually use the command `dt"` and `dt[` to delete the content from the current position to the mark [ or ".
>
> Is there a way that use the commannd `dtt`(for example) to combine the two `dt[` and `dt"` command?
>
> for example , `$` mark the current position of the curor.
> 1. "aaaa$bbbb"[cccccddddd] ; command dtt delete bbbb
> 2. "aaaabbbb"[ccccc$ddddd] ; command dtt delete ddddd
> 3. [ccccc"aaaa$bbbb"ddddd] ; command dtt delete bbbb, find the " or ] which is closer to the current curor

I assume you want to find either the '[', ']' or the '"', so you can use
a search:
d/[[\]["]

which you could map to a custom key if you like:

nnoremap <leader>d d/[[\]["]<cr>

Note however, since a search is not limited to the current line, this
might delete until the next line. If you don't want this, you could
adjust the command to this:

nnoremap <expr> <leader>d 'd/[[\]["]\%<c-r>=line(".")<cr>l<cr>'


Best,
Christian
--
Der Schwache kann nicht verzeihen. Verzeihen ist eine Eigenschaft des Starken.
-- Mahatma Gandhi

李哲

unread,
Jun 4, 2016, 10:36:48 PM6/4/16
to vim_use
在 2016年6月4日星期六 UTC+8下午3:59:38,Christian Brabandt写道:
yeah it helped , tnx a lot : )
Reply all
Reply to author
Forward
0 new messages