How to delete a string between spaces?

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

How to delete a string between spaces?

Peng Yu
Hi,

daw only delete a word. I need to delete something between spaces. For
example, I want to delete the whole string "$abc$", rather than just
"abc". Is there a convenient way to do so?

Regards,
Peng

--
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
Reply | Threaded
Open this post in threaded view
|

Re: How to delete a string between spaces?

thinca
Try diw
See also :help iw

--
thinca <[hidden email]>

--
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
Reply | Threaded
Open this post in threaded view
|

Re: How to delete a string between spaces?

Tim Chase
In reply to this post by Peng Yu
On 05/12/12 05:49, Peng Yu wrote:
> daw only delete a word. I need to delete something between
> spaces. For example, I want to delete the whole string "$abc$",
> rather than just "abc". Is there a convenient way to do so?

you can use "W" instead of "w" to see if either

  diW
  daW

does what you want.

-tim



--
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
Reply | Threaded
Open this post in threaded view
|

Re: How to delete a string between spaces?

rongchao gao
Hi,
you can use 3dw to delete the whole string.

2012/5/12 Tim Chase <[hidden email]>
On 05/12/12 05:49, Peng Yu wrote:
> daw only delete a word. I need to delete something between
> spaces. For example, I want to delete the whole string "$abc$",
> rather than just "abc". Is there a convenient way to do so?

you can use "W" instead of "w" to see if either

 diW
 daW

does what you want.

-tim



--
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 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
Reply | Threaded
Open this post in threaded view
|

Re: How to delete a string between spaces?

Matteo Landi-2
In reply to this post by Peng Yu
On May/12, Peng Yu wrote:
> Hi,
>
> daw only delete a word. I need to delete something between spaces. For
> example, I want to delete the whole string "$abc$", rather than just
> "abc". Is there a convenient way to do so?
>
> Regards,
> Peng

Have you tried with daW (capital W)?


Cheers,
Matteo

>
> --
> 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

--
http://www.matteolandi.net

--
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
Reply | Threaded
Open this post in threaded view
|

Re: How to delete a string between spaces?

Peng Yu
In reply to this post by Tim Chase
On Sat, May 12, 2012 at 6:21 AM, Tim Chase <[hidden email]> wrote:

> On 05/12/12 05:49, Peng Yu wrote:
>> daw only delete a word. I need to delete something between
>> spaces. For example, I want to delete the whole string "$abc$",
>> rather than just "abc". Is there a convenient way to do so?
>
> you can use "W" instead of "w" to see if either
>
>  diW
>  daW
>
> does what you want.

Thanks Tim, Matteo and thinca,

I want to delete a word in the context of the file that I'm editing
using the same command. daW will delete the whole string, which is
undesirable for perl. How to customize a dw command that can correctly
delete a word depending on the context?

word1($word2)

--
Regards,
Peng

--
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
Reply | Threaded
Open this post in threaded view
|

Re: How to delete a string between spaces?

Christian Brabandt
Hi Peng!

On Sa, 12 Mai 2012, Peng Yu wrote:

> On Sat, May 12, 2012 at 6:21 AM, Tim Chase <[hidden email]> wrote:
> > On 05/12/12 05:49, Peng Yu wrote:
> >> daw only delete a word. I need to delete something between
> >> spaces. For example, I want to delete the whole string "$abc$",
> >> rather than just "abc". Is there a convenient way to do so?
> >
> > you can use "W" instead of "w" to see if either
> >
> >  diW
> >  daW
> >
> > does what you want.
>
> Thanks Tim, Matteo and thinca,
>
> I want to delete a word in the context of the file that I'm editing
> using the same command. daW will delete the whole string, which is
> undesirable for perl. How to customize a dw command that can correctly
> delete a word depending on the context?
>
> word1($word2)

da(

regards,
Christian

--
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
Reply | Threaded
Open this post in threaded view
|

Re: How to delete a string between spaces?

Tim Chase
In reply to this post by Peng Yu
On 05/12/12 08:22, Peng Yu wrote:
> I want to delete a word in the context of the file that I'm editing
> using the same command. daW will delete the whole string, which is
> undesirable for perl. How to customize a dw command that can correctly
> delete a word depending on the context?
>
> word1($word2)

You can tweak the 'iskeyword' setting to include other characters if
it makes sense to you.  So you could do

  :setlocal isk+=$

to make it consider "$" part of a "word".  Or, as Christian
suggests, in your particular use-case, use "di("

-tim



--
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
Reply | Threaded
Open this post in threaded view
|

Re: How to delete a string between spaces?

Peng Yu
On Sat, May 12, 2012 at 9:49 AM, Tim Chase <[hidden email]> wrote:

> On 05/12/12 08:22, Peng Yu wrote:
>> I want to delete a word in the context of the file that I'm editing
>> using the same command. daW will delete the whole string, which is
>> undesirable for perl. How to customize a dw command that can correctly
>> delete a word depending on the context?
>>
>> word1($word2)
>
> You can tweak the 'iskeyword' setting to include other characters if
> it makes sense to you.  So you could do
>
>  :setlocal isk+=$
>
> to make it consider "$" part of a "word".  Or, as Christian
> suggests, in your particular use-case, use "di("

Most plugins do not change isk. If I want to customize isk as you
pointed without modifying the plugins (for different file type) that I
installed. Where I should put the setlocal command? Thanks!

Also da( does not work for me. Is there anything wrong with this command?

--
Regards,
Peng

--
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
Reply | Threaded
Open this post in threaded view
|

Re: How to delete a string between spaces?

Tim Chase
On 05/12/12 09:56, Peng Yu wrote:

> On Sat, May 12, 2012 at 9:49 AM, Tim Chase <[hidden email]> wrote:
>> You can tweak the 'iskeyword' setting to include other characters if
>> it makes sense to you.  So you could do
>>
>>  :setlocal isk+=$
>>
>> to make it consider "$" part of a "word".  Or, as Christian
>> suggests, in your particular use-case, use "di("
>
> Most plugins do not change isk.

I agree that plugins ought not change 'isk'.  However, I didn't
catch that was part of your requirement.

> If I want to customize isk as you
> pointed without modifying the plugins (for different file type) that I
> installed. Where I should put the setlocal command? Thanks!

You'd set it in your filetype plugin file.

> Also da( does not work for me. Is there anything wrong with this command?

Christian and I recommended "di(", not "da(".

-tim



--
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
Reply | Threaded
Open this post in threaded view
|

Re: How to delete a string between spaces?

Christian Brabandt
Hi Tim!

On Sa, 12 Mai 2012, Tim Chase wrote:

> Christian and I recommended "di(", not "da(".

I think, I said da( because I thought he wanted to remove the
parenthesis as well.

regards,
Christian
--
Wir lieben die Achtung nicht um der Achtung willen, sondern einzig
und allein nur wegen der Vorteile, die sie uns bringt.
                -- Claude Adrien Helvétius

--
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