You are here

Vim

Configuring Vim/Gvim to use spaces instead of TABs for indentation

Submitted by Druss on Wed, 2011-08-10 03:00

Some people like to indent their code using TABs. I used to like doing this. I still think that it's a good idea. But circumstances have dictated for the past several years that I need to indent using spaces instead. My favourite command-line editor in Linux and text editor in Windows is VIM / Gvim (where Gvim is basically Vim with a GUI). To configure this editor to override its default and use spaces instead of TABs for indentation, perform the following steps:

Vim: Going to the nth character in a file

Submitted by Druss on Sun, 2010-08-15 00:05

I ran into an error message today that only specified the character number in a configuration file without making any reference to the line number. Rather odd. In any case, since Vim (and my usual preference, GVim) is an excellent editor, I expected this to be a cinch. Unfortunately, a few minutes of head-scratching later, I was still quite clueless as to how to accomplish this seemingly routine task.

I do know that typing:
:1000
will move the cursor to the 1000th line in the file.

Vim: Scrolling a file with no line-breaks

Submitted by Druss on Sat, 2010-08-14 23:56

When a file has no line-breaks and is just one single line, navigating line by line is obviously not an option. Some editors wrap the text and treat each pseudo-line as a separate element and allow us to scroll through them. Others don't. Vim, by default doesn't.

Or to be more precise, Vim (and GVim) do not allow us to scroll through such files using the arrow keys. Instead, the following short-cuts do the business:

Scroll up: g, k / g, up
Scroll down: g, j / g, down
Beginning of the line: g, ^ [i.e. g, SHIFT + 6 on a keyboard with a US layout]

Pages

Subscribe to RSS - Vim