In Vim, how do I remove a word suffix?

In vim, in normal mode, if the cursor is in a word and not in the last letter, de removes the suffix of the word from the cursor position. If the cursor is on the last letter, x also does this, and de will jump to the end of the next word.

Which command would you use, will it work in both cases, the last letter or not?

The goal is to include the command in the macro.

+6
source share
4 answers

Try vwged instead of de and define a mapping like the following if you are like this.

 :nnoremap <leader>de vwged 

It seems that you are doing exactly what you want.

+4
source

You can also try d/\> , which translates to remove to the border of the next end of the word.

+2
source

If your word separator is a space, dt<space> will work. t will match all characters up to the specified character.

+1
source
 :s/\w\+// 

This will be replaced at the beginning of the line. To substitute it at the cursor position, you must add some lines to your vimrc. Follow the instructions here.

http://vim.wikia.com/wiki/Repeating_a_substitute_from_current_cursor_position

+1
source

Source: https://habr.com/ru/post/888748/


All Articles