worked on vim article

This commit is contained in:
Jacob 2018-03-03 09:24:06 +01:00
parent 702661e39b
commit c0004665de

View File

@ -1,12 +1,38 @@
![](/../images/2017-12-02/a.png) ![](/../images/2017-12-02/a.png)
<time datetime="2017-12-02">2017-12-02</time> <time datetime="2018-02-23">2018-02-23</time>
before learning to use Vim, I was intrigued by it, but had a really hard time undeesranding why anyone wouæd go to the trouble of learning to use such a difficult control scheme. Well, the answer was... there isn't that much to learn. If you have a regulare keyboard for example, there is no reason to start using hjkl instead. This is a dangerous thing to claim, but in regards to using vim... there isn't actually that much to learn.
Second, coding is often mostly about editing, and boy does vim make that easier: It's easy to jump to the beginning or end of words, sentences, inside parenthesis or the entire document.
Cut all inside deliminator and go into insert mode? c+i+[deliminator]. Cut the next two lines? 2+d+d. Change a word? c + i + w + [new word]. Second, coding is often mostly about editing, and boy (*copyrighted mouse whiste*) does Vim make that easy.
Do that again somewhere else? Just press period. There are variations to these actions, but it's mostly stuff like that, that is so amazing when using Vim. Editing is _quick_!
The problem is that normal actions are a bother for a first time: Search for a word? Press forward slash. Save? press colon + w. Quit? Colon + q. Open another file while inside Vim? Colon + e and then write the fucking path yourself you lazy millenial. Or install plugins. Fucking plugins. It's insane to ask that as the first thing, but you will god damn need some plugins. 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.