DEV Community

Discussion on: 15 Vim shortcuts that will make your life easier

Collapse
 
moopet profile image
Ben Sinclair

I think some of these are slightly wrong:

w and b move forwards and backwards in normal mode, not command mode. In command mode, you have the little : prompt and can enter instructions for the editor to execute.

dw deletes from the cursor to the start of the next "word". To delete the word you're currently on, you'd use diw, daw, diW, or daW depending on exactly how you wanted to do it.

:%s/old/new will replace "old" with "new" in every line of the file, but it will only replace the first occurence of "old" in each line. If you want to replace every occurence, you'd pass the g flag like so: :%s/old/new/g

Your :w example suggests that it will use the filename "sample_filename" but you haven't put that in the command. It'd need to be :w sample_filename for that to work!

Collapse
 
sneh27 profile image
Sneh Chauhan

Thank you for your feedback Ben! I've made the corrections accordingly.

Collapse
 
grizzlysmit profile image
Francis Grizzly Smit

or to delete from the cursor to the end of the word you are on de