The Vimer a Vim Primer

Reading time ~3 minutes

So you accidentally opened vim can’t figure out how to close it and now are here.

Don’t Panic

Vim is easier than it looks and you will be on your way to using it as well as any normal text editor in less than a minute.

ESC is your friend

Assuming you hit a bunch of random keys when you first opened it, the first thing you probably need to do is spam the ESC key until it looks like it will behave.

Welcome to Command Mode

You should hopefully now be in command mode…. where you issue commands. Vim has lots of commands, whole desktop wallpapers worth, we don’t care about any of those. We just want to move around and edit some text.

h, j, k, l -> Basic movement

These keys will move your cursor around, you can also use the arrow keys if your brain refuses to think of j as down.

i -> insert mode

Welcome to your second mode in Vim, pressing the i key will put you in insert mode, now you can type out text like you are used to. Whenever you are done you probably want to save it though so remember our friend the ESC key, jam him 5 or 6 times just to be safe to move back to command mode.

:w -> write

When you are in command mode (you did hit ESC 6 times right) type :w and hit enter. That should spit out some text at the bottom about how you wrote to some file.

:q -> quit

Looks like we are done here, while in command mode (hit ESC 7 or 12 times just to be sure) :q and enter will quit. For convenience you can put :w and :q together like :wq to save and quit at the same time.

Congratulations

You can now use vim just as well as any other text editor.

Advanced Vimer

But wait you ask, what about copy/paste and finding/replacing text, my normal text editor does those, can’t the mighty Vim.

v -> visual mode

If you want to copy and paste some text, the first thing you probably want to do is select the text to be copied, an intuitive way to do this in vim is to use Visual mode. While in command mode you can press v to enter visual mode. While in visual mode you will be able to highlight text and commands you type will normally happen against the selected text, for example copying.

y -> copy (yank)

With text highlighted you can press the y key in visual mode to copy the selected text. If full lines of text are your thing you can press yy in command mode to copy the entire current line.

p -> paste

Pasting is as simple as pressing p in the right place, while in command mode.

/ -> finding

While in command mode, you can use the / command followed by text to search the currently open file for it. By default it will search from the top of the file, when you have put in the text you want to search for you can press enter to move the cursor to the first instance, from here you can use n to move forward and N to move backwards. You will often find that the upper case version of a command in Vim will do the reverse.

:%s/find/replace/g -> find/replace

This command is a little complex, but extremely powerful. Like all things that start with : this is run from command mode, however it can be run from visual mode as well if you drop the %. In the example we are replacing all instances of find with replace. You can put regular expressions into this allowing you some very powerful finding/replacing.

Comparing Triple Stores

In looking into the world of triple stores there, exists very little in the way of traditional web communities discussing and comparing t...… Continue reading