Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I delete a word and previous white space in VIM?

^ denotes char under cursor for vim

Please dont answer with T motion because it will require me to know the last character , which helps me but I want to know if there is any other way

I have a line of text:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

these are test words

now if I want to delete the word test.

If my cursor is at the beginning of the word

these are test words
          ^

I press dw it does exactly what I want, deletes test and spaces after it till next word ie ‘words’, I understand this works because w motion is exclusive and it doesn’t include the beginning character of next word

However if I am at end of the word then how can I delete towards left direction and remove those white spaces (between are and ‘test’ as well):

these are test words
             ^

when I press dgE it deletes the e at the end of are as it tries to reach the end of previous word and deletes it as well, resulting in

these ar words

I tried to force this command to be exclusive but it excludes on right side and not on left side

I want end result to be:

these are words

Please dont answer with T or F motion

>Solution :

Press daw (mnemo: delete a word) as explained in :help aw. It will delete the entire word and the white space behind it.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading