#TIL

Today I Learned

View on GitHub

Navigating between words in VIM

Often find myself navigating vim using word boundaries. I use w (word) to move from word from word, and e (end of word) when I want to go the end of a word. To go back a word, I use b (back).

So changing a word becomes ce (change to the end of word), deleting a word de (delete to the end of word).

Often I dont want to remove the whole word, just some boundary. For example if you have a long variable name like some_long_ass_variable_name, I’d like to remove the first portion. I can navigate to the underscore boundary with t_ (till underscore). To delete until the underscore, I’d do dt_, but that would leave _long_ass_variable_name. To remove everything including the boundary, use f as in df_.

Bonus: Last file’s path

The previously closed files path is aliases to #, just like to can do :!echo % to see the current file’s path, you can do :!echo # to see the last opened files’ path. To re-open last file, simple do :edit # or shorten to :e#.