Deleting a word backwards

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

Deleting a word backwards

Chris Allen
Hello all,

Is there a way to delete words backwards similar to diw (I've just
scoured the help and I can't find anything that goes backwards).
Here's an example, say I'm doing Java and I type:

public class ARe<c-x><c-f>

Which expands (via file name completion) to:

public class AReallyLongClassNameInAccordanceWithClassNamingConventions.java

Now, obviously I can't be bothered typing this again after having
already typed it out once to save it[1], but the .java extension left
by file completion is really awkward.  What I'd like to do is 2dib
(which makes perfect sense to me, but doesn't work).  I could do
2b2diw, but that starts to feel like work.

Any suggestions?  Have I missed something?

Thanks,
Chris Allen

[1] In fact, thanks to Vim's completion facilities I have no intention
of ever typing it again in my life.
Reply | Threaded
Open this post in threaded view
|

Re: Deleting a word backwards

Marian Csontos
On Fri, 17 Feb 2006 14:17:43 +0100, Chris Allen <[hidden email]>  
wrote:

> Hello all,
>
> Is there a way to delete words backwards similar to diw (I've just
> scoured the help and I can't find anything that goes backwards).
> Here's an example, say I'm doing Java and I type:
>
Hi Chris,

Does 2db work as intended?

Regards

-- Marian


________ Information from NOD32 ________
This message was checked by NOD32 Antivirus System for Linux Mail Server.
  part000.txt - is OK
http://www.nod32.com
Reply | Threaded
Open this post in threaded view
|

Re: Deleting a word backwards

A.J.Mechelynck
In reply to this post by Chris Allen
Chris Allen wrote:

> Hello all,
>
> Is there a way to delete words backwards similar to diw (I've just
> scoured the help and I can't find anything that goes backwards).
> Here's an example, say I'm doing Java and I type:
>
> public class ARe<c-x><c-f>
>
> Which expands (via file name completion) to:
>
> public class AReallyLongClassNameInAccordanceWithClassNamingConventions.java
>
> Now, obviously I can't be bothered typing this again after having
> already typed it out once to save it[1], but the .java extension left
> by file completion is really awkward.  What I'd like to do is 2dib
> (which makes perfect sense to me, but doesn't work).  I could do
> 2b2diw, but that starts to feel like work.
>
> Any suggestions?  Have I missed something?
>
> Thanks,
> Chris Allen
>
> [1] In fact, thanks to Vim's completion facilities I have no intention
> of ever typing it again in my life.

If you're at the end of a word, d2b (or 2db) should work. After a
command that requires a motion, you can use any motion, not just a
text-object. (the i [inner] prefix must, IIUC, be followed by a
text-object.)


Best regards,
Tony.

Reply | Threaded
Open this post in threaded view
|

Re: Deleting a word backwards

Chris Allen
On 2/17/06, A. J. Mechelynck <[hidden email]> wrote:
> If you're at the end of a word, d2b (or 2db) should work. After a
> command that requires a motion, you can use any motion, not just a
> text-object. (the i [inner] prefix must, IIUC, be followed by a
> text-object.)

Ah, that does work for the specific case, thanks to being on the final
character of the word.  Thank you.  It would be nice if there was a
way to do it more generically by words rather than by character
motions, though (just for those cases where the cursor isn't at a word
boundary).

Thanks,
Chris Allen
Reply | Threaded
Open this post in threaded view
|

Re: Deleting a word backwards

A.J.Mechelynck
Chris Allen wrote:

> On 2/17/06, A. J. Mechelynck <[hidden email]> wrote:
>> If you're at the end of a word, d2b (or 2db) should work. After a
>> command that requires a motion, you can use any motion, not just a
>> text-object. (the i [inner] prefix must, IIUC, be followed by a
>> text-object.)
>
> Ah, that does work for the specific case, thanks to being on the final
> character of the word.  Thank you.  It would be nice if there was a
> way to do it more generically by words rather than by character
> motions, though (just for those cases where the cursor isn't at a word
> boundary).
>
> Thanks,
> Chris Allen

If you're not on the last character, then ed2b does it. And if you're at
the end of the line, I don't know if 2diw works, or if you must do diwdiw .

Best regards,
Tony.

Reply | Threaded
Open this post in threaded view
|

Re: Deleting a word backwards

Jean-Rene David-2
In reply to this post by Chris Allen
* Chris Allen <[hidden email]>:
> public class ARe<c-x><c-f>
>
> Which expands (via file name completion) to:
>
> public class AReallyLongClassNameInAccordanceWithClassNamingConventions.java

You already got some answers, but going back to
the original problem, would that perhaps to what
you want:

imap <c-f> <c-x><c-f><esc>F.cE

HTH,

--
JR
Reply | Threaded
Open this post in threaded view
|

Re: Deleting a word backwards

Gerald Lai-2
In reply to this post by Chris Allen
On Fri, 17 Feb 2006, Chris Allen wrote:

> On 2/17/06, A. J. Mechelynck <[hidden email]> wrote:
>> If you're at the end of a word, d2b (or 2db) should work. After a
>> command that requires a motion, you can use any motion, not just a
>> text-object. (the i [inner] prefix must, IIUC, be followed by a
>> text-object.)
>
> Ah, that does work for the specific case, thanks to being on the final
> character of the word.  Thank you.  It would be nice if there was a
> way to do it more generically by words rather than by character
> motions, though (just for those cases where the cursor isn't at a word
> boundary).

You may want to take a look at Ctrl-w in Insert mode. To do what you
want, it would require 2 keystrokes (double <C-w>) after <C-x><C-f> as
opposed to 4 keystrokes <C-o>d2b. See ":help i_ctrl-w". Hope this helps
somewhat.
--
Gerald
Reply | Threaded
Open this post in threaded view
|

Deleting a buffer for good

Jack Donohue
I try :bd then do Ctrl^ and I go back to the buffer I just deleted.  Someone
once told me :bf is supposed to really get rid of it but that does the same
thing.  I'm still back on Vim 6.3 so I'm wondering if this behavior has
changed or is there another way to get rid of a buffer for good.

Thanks,


Jack

Reply | Threaded
Open this post in threaded view
|

Re: Deleting a buffer for good

Benji Fisher
On Fri, Feb 17, 2006 at 02:50:01PM -0500, Jack Donohue wrote:
> I try :bd then do Ctrl^ and I go back to the buffer I just deleted.  
> Someone once told me :bf is supposed to really get rid of it but that does
> the same thing.  I'm still back on Vim 6.3 so I'm wondering if this
> behavior has changed or is there another way to get rid of a buffer for
> good.

     I think you want :bw .

:help :bwipe

HTH --Benji Fisher
Reply | Threaded
Open this post in threaded view
|

Re: Deleting a buffer for good

A.J.Mechelynck
In reply to this post by Jack Donohue
Jack Donohue wrote:

> I try :bd then do Ctrl^ and I go back to the buffer I just deleted.
> Someone once told me :bf is supposed to really get rid of it but that
> does the same thing.  I'm still back on Vim 6.3 so I'm wondering if this
> behavior has changed or is there another way to get rid of a buffer for
> good.
>
> Thanks,
>
>
> Jack
>
>
>

":bdelete" marks the buffer as "unlisted" but doesn't actually delete it
(":ls!", with bang, will still show it). ":bwipeout" removes all trace
of the buffer. This distinction is one of the differences between
versions 5 and 6; it hasn't changed in Vim 7.

See
        :help :bdelete
        :help :bwipeout
        :help new-unlisted-buffers


Best regards,
Tony.

Reply | Threaded
Open this post in threaded view
|

Re: Deleting a word backwards

Marian Csontos
In reply to this post by Jean-Rene David-2
On Fri, 17 Feb 2006 15:41:39 +0100, Jean-Rene David <[hidden email]>  
wrote:

> * Chris Allen <[hidden email]>:
>> public class ARe<c-x><c-f>
>>
>> Which expands (via file name completion) to:
>>
>> public class  
>> AReallyLongClassNameInAccordanceWithClassNamingConventions.java
>
> You already got some answers, but going back to
> the original problem, would that perhaps to what
> you want:
>
> imap <c-f> <c-x><c-f><esc>F.cE
>
> HTH,
>

Hi all,

In this case it is usable and OP is aware of them, but IMO OP wants to ask  
for new object type - as iw expands to the right, so it seems logical that  
ib expands to the left.

Best regards

-- Marian


________ Information from NOD32 ________
This message was checked by NOD32 Antivirus System for Linux Mail Server.
  part000.txt - is OK
http://www.nod32.com
Reply | Threaded
Open this post in threaded view
|

Re: Deleting a word backwards

Chris Allen
On 2/20/06, Marian Csontos <[hidden email]> wrote:
> In this case it is usable and OP is aware of them, but IMO OP wants to ask
> for new object type - as iw expands to the right, so it seems logical that
> ib expands to the left.

I think that would have been a nice, consistent touch, originally.
Unfortunately, it can not be done now as ib and iB are already
allocated for inner block and inner Block.  (Which I only found after
asking.)

Thanks,
Chris Allen
Reply | Threaded
Open this post in threaded view
|

Re: Deleting a word backwards

Antony Scriven
In reply to this post by Chris Allen
On Feb 17, Chris Allen wrote:

 > Is there a way to delete words backwards similar to diw
 > (I've just scoured the help and I can't find anything
 > that goes backwards). Here's an example, say I'm doing
 > Java and I type:
 >
 > public class ARe<c-x><c-f>
 >
 > Which expands (via file name completion) to:
 >
 > public class AReallyLongClassNameInAccordanceWith
 > ClassNamingConventions.java

Pretend that's all one line: I've split it.

 > Now, obviously I can't be bothered typing this again
 > after having already typed it out once to save it[1], but
 > the .java extension left by file completion is really
 > awkward.  What I'd like to do is 2dib (which makes
 > perfect sense to me, but doesn't work).  I could do
 > 2b2diw, but that starts to feel like work.
 >
 > Any suggestions?  Have I missed something?

Some suggestions, but I'm not sure whether you want to
remain in insert mode or not, etc, nor whether I've
understood you correctly. Perhaps:

   ^W^W (in insert mode, naturally)
   F.C
   dF.s
   db.s
   bbC
   2bC
   2dbs
   daws
   daw.
   2bd2w
   ax2bd2w

The last one is more general, but could still cause problems
at the very beginning of a buffer.

Antony
Reply | Threaded
Open this post in threaded view
|

Re: Deleting a buffer for good

DogWalker
In reply to this post by A.J.Mechelynck
"A. J. Mechelynck" <[hidden email]> said:

>Jack Donohue wrote:
>> I try :bd then do Ctrl^ and I go back to the buffer I just deleted.
>> Someone once told me :bf is supposed to really get rid of it but that
>> does the same thing.  I'm still back on Vim 6.3 so I'm wondering if this
>> behavior has changed or is there another way to get rid of a buffer for
>> good.
>>
>> Thanks,
>>
>>
>> Jack
>>
>>
>>
>
>":bdelete" marks the buffer as "unlisted" but doesn't actually delete it
>(":ls!", with bang, will still show it). ":bwipeout" removes all trace
>of the buffer. This distinction is one of the differences between
>versions 5 and 6; it hasn't changed in Vim 7.
>
>See
> :help :bdelete
> :help :bwipeout
> :help new-unlisted-buffers
>
>
>Best regards,
>Tony.
>
The :help :bwipeout contains this sentence:

   Don't use this unless you know what you are doing.

How can you know if "you know what you are doing"?
Reply | Threaded
Open this post in threaded view
|

Re: Deleting a buffer for good

A.J.Mechelynck
DogWalker wrote:

> "A. J. Mechelynck" <[hidden email]> said:
>
>> Jack Donohue wrote:
>>> I try :bd then do Ctrl^ and I go back to the buffer I just deleted.
>>> Someone once told me :bf is supposed to really get rid of it but that
>>> does the same thing.  I'm still back on Vim 6.3 so I'm wondering if this
>>> behavior has changed or is there another way to get rid of a buffer for
>>> good.
>>>
>>> Thanks,
>>>
>>>
>>> Jack
>>>
>>>
>>>
>> ":bdelete" marks the buffer as "unlisted" but doesn't actually delete it
>> (":ls!", with bang, will still show it). ":bwipeout" removes all trace
>> of the buffer. This distinction is one of the differences between
>> versions 5 and 6; it hasn't changed in Vim 7.
>>
>> See
>> :help :bdelete
>> :help :bwipeout
>> :help new-unlisted-buffers
>>
>>
>> Best regards,
>> Tony.
>>
>
> The :help :bwipeout contains this sentence:
>
>    Don't use this unless you know what you are doing.
>
> How can you know if "you know what you are doing"?

Once you use ":bwipeout", all trace of the concerned buffer(s) is lost
from memory. For instance, marks for that buffer (including, IIUC, the
cursor position) will be forgotten. The buffer name will also disappear
from the ":ls!" listing (even with ! which shows unlisted buffers),
possibly leaving a "hole" in the numbering since other buffers won't be
re-numbered. If that buffer is the "alternate file name", there won't be
an "alternate file name" after you wipe it out.

If that's what you want, go ahead. OTOH, if you want marks, etc. to be
remembered, then don't wipe out the buffer: ":bdelete" is now
(partially) reversible (from v6 on), ":bwipeout" isn't.

See _all three_ help topics mentioned in my previous post, and also
":help unlisted-buffer", linked from ":help :bdelete".


Best regards,
Tony.