A year ago, when I was transitioning to Linux, I also started using Vim. I had for many years lived in the impression that Vim was something for the nerds who enjoy something complicated and impractical, but then I realized I spend 10 hours in front of the computer every day. I concluded that investing time in becoming more efficient in text editing was absolutely worthwhile (which is also the reason why I learned Dvorak). Today, I have become fairly efficient in Vim, and I'm starting to think it was well worth the pain. In this post I will share one of my favorite commands, ciw.

ciw is an abbreviation of change inner word and is used, well you guessed it, to change a word in the text. c followed by a text object selection command will delete the selected text and put you in insert mode so you can start typing immediately (change the word). iw will select a word (look it up, it's a clear definition) without any neighboring spaces. c can be replaced by another command, like d (will delete the text but not enter insert mode). If you want to change anything else than a word, you can replace iw with some other text selection command, like i(, which selects everything inside the current parentheses.

The reason why I find ciw particularly handy while programming is because the inner word matches text I would normally want to change, like a variable name, function name, or a class attribute. ciw makes renaming easy, and is especially handy if you have some copied lines where you want to edit nothing but some variable names.

Remember that you can use . to repeat the previous command, which means if you have changed the name of one variable, moving the cursor to another variable you want to give the same name, you can press .. This command has saved me lots of time while filling out truth tables where I constantly had to switch values between True and False.