So while I was gone, I discovered vim was actually a viable tool. Back then, I was surely… Unenlightened. I looked up how you use the damn thing because you can’t just start typing right away for some reason (as I said, I was unilluminated). So, I learned how to go into insert mode. That was using the key
i. And to get out of vim, press the escape key then type
:wq to save and quit (
:q! to not save changes and quit). Simple right?
Moving the cursor
Another fundamental thing is moving the cursor. This is done by using the motion commands:
h for right,
j for down (Hint: The letter
jlooks like a down arrow),
k for up,
l for right (not left!).
It is possible to use arrow keys, but
hjkl is in the home row, so it is faster to use.
After learning how to write, I learned some really basic powers of vim. Such as
e to move between words.
e moves the cursor to the end of the word. If you already are there, it moves the cursor to the end of the next word.
w always moves the cursor to the start of the next word.
b moves the cursor to the beginning of the word. Just like
e, if you are already there it moves the cursor to the beginning of the previous word.
There is also
ge, which always moves the cursor to the end of the previous word, just like
Delete (cut), change and yank (copy)
In a normal text editor, you can cut, copy, paste. Vim can do that too! (V)Impressive right?
The keys for these are:
y for yank (copy),
d for delete (cut), and lastly
c for change.
Yanking in vimspeak, is copying a piece of text. Deleting in vimspeak, is copying and and erasing the text. Changing, is deleting (deleting and copying), and going into insert mode right after.
If you have copied any text using these commands, you can use
p to paste the text you have copied after the cursor.
P is the same thing, but it pastes the text before the cursor.
These commands are appended a “motion”. A motion is just a command that only moves the cursor. Such as
w b e ge. The command you use is applied to all of the characters that the motion goes over.
bdw goes to the beginning of the word (or if you are already there, the beginning of the prev. word) and deletes from there until the start of the next word.
Words and WORDS, there is a difference
A word in vim is a string of letters, numbers, and underscores. They are seperated by everything else. (Those “everything else”s can form words too, as you will see below.) But a WORD on the other hand, is a string of non-whitespace characters.
String: olcay!?ora nsoy/) olcay !? ora nsoy /) Words in this line are seperated by spaces olcay!?ora nsoy/) WORDS in this line are seperated by spaces
Every word movement maps to a corresponding WORD movement, seen below:
Word mv. -> WORD mv. w -> W e -> E b -> B ge -> gE
What I have told you is enough for the first steps, but this is just a speck in an endless void of tools.
This is all for this post, in the future I will expand on this topic further. Stay tuned for part 2 where I show off more stuff, bye!
P.S. I’m baack!