takunomi-blog/drafts/vim.md

2.3 KiB

This is a dangerous thing to claim, but in regards to using vim... there isn't actually that much to learn.

It's easy to jump to the beginning or end of words, sentences, inside parenthesis or the entire document.

Second, coding is often mostly about editing, and boy (copyrighted mouse whiste) does Vim make that easy.

Cut everything inside a deliminator? easy. Cut the next two lines? You didn't even have time to blink. Change a word? Double easy.

The problem is that normal actions are a bother for a first timer: Search for a word? Press forward slash. Go to the next word? Press lower case n. Previous? Capital N. Save/Quit the document? Oof, that's a little different. Open another file while inside Vim? Difficult and write the fucking path yourself, you lazy millenial. Or install a plugin. Fucking plugins. It's insane to ask that as the first thing to do, but you will god damn need some plugins.

Really, most introductions and guides make it sound like Vim is this huge task to overcome, when really, it can be summarized to just a few smart commands:


  • [c]hange [i]nside [deliminator]/[w]ord

  • [c]hange [a] [deliminator]/[w]ord

    Can be used to delete a word, sentence, everything inside a method, or perhaps a string value. They're mostly the same command. Pressing ciw or ci" or ca{ might sound difficult, but seriously, think about how often you ned to select, cut or delete something inside a string or curly brace when you code?


  • {number} [d]elete [d]elete

  • {number} [y]ank [y]ank

    Respectively cuts or copies a number of lines. Without number, it's just the current line. Can be pasted. This is the simplest command. Pressing 2dd or simply dd and then p somewhere else to paste, is such a delicious way to move stuff around in code. Did you need that line to come before that one? dd, move cursor up and p. Done. And yes I know simply pressing ctrl c or ctrl x in Sublime Text cuts the copies or cuts the current line, but this. is. better.


  • [p]aste

    Pastes the last cut/copy below current line. Using capital [P], you paste above current line.


Of course there is more to Vim, but these are really the most important tools. I use them a fucking lot when working.