Vim is best used when it is configured for the users needs. Vim has a slew of configurations to develop the type of environment the user requires to do numerous different tasks from spell checking to color syntaxing. There are thousands of scripts and color themes available on the Vim website that can add even more abilities.
I talked yesterday of learning Vim and perhaps just as important is tailoring one’s own configuration file (
~/.vimrc). The best place to start is finding a person's
~/.vimrc who is already experienced in Vim. Some distro's may install a custom
~/.vimrc already so it's best to take a look. I personally use Brians Carpers
~/.vimrc which does a good job for me. There are literally thousands out there and people like to share them, so pick the right one for whatever Vim needs to do.
Setting up the terminal and Vim correctly are important parts for long periods in front of the terminal. To help ease reading and prevent eye strain a couple things that can help are choosing a lower-contrast colorscheme and properly sizing the width of the terminal
To pick a colorscheme that is comfortable for viewing for long periods go ahead and start up Vim -
/etc/X11/xorg.conf can provide a good example. Now type:
follow by a space. Now press "tab" for tab-completion - pressing tab will cycle through the available color schemes. For example, this one is called pyte:
72 Section "InputDevice"
73 Identifier "Generic Keyboard"
74 Driver "kbd"
75 Option "CoreKeyboard"
76 # Option "XkbRules" "pc104"
77 Option "XkbLayout" "us"
78 Option "XkbLayout" "en_US"
79 Option "XkbModel" "macintosh"
80 # Option "XkbVariant" "apple"
83 Section "InputDevice"
84 Identifier "Configured Mouse"
85 Driver "mouse"
86 Option "CorePointer"
87 Option "Device" "/dev/input/mice"
88 Option "Protocol" "auto"
89 Option "ZAxisMapping" "4 5"
For xterm users (gnome-terminal, stjerm, tilda?, others?...) it's likely that the terminal is set to eight bit color for compatibility reasons (see my post from a couple days ago). Vim though can display in 256 colors and will need to for alot of these colorschemes to work. To set Vim to 256 colors, add the setting to the
New colorschemes can be found in at the Vim website. To get a good idea what they look like before installed take a look at Vim Color Scheme Test. Color schemes need to be put in
~/.vim/colors and then a color scheme can be permanently added by putting them in the
The width of the terminal is also important. The human eye can only scan about 10 words before it loses focus (i.e. has difficulty scanning to the next line). Most text in Linux is written with a margin of 72 or 80 characters. Most editors also use a soft-returns (i.e. not a hard line break). Use whatever is best by resizing the window to fit this many characters. Vim cannot set a soft-return and rather uses the window width. This is unfortunate as some terminal apps (tilda, and yakuake) use the entire width of the screen - yes vim has settings like "textwidth" and "wrapmargin" but they create hard-returns, so having a wide terminal is not a good idea with Vim.
A few tips I picked up along the line.
- Vim has great help documentation.
:help topiccan be done on about anything.
- Vim has tab-completion for entering commands and bash-completion for files (e.g.
- The mouse can be used in Vim for some functions, but it needs to be enabled. I use this setting as I find that moused in visual mode can be distractive.
- To be able to select text with the mouse in this mode hold the shift key
I Insert at beginning of line A Append to end of line
- Tab-mode rules:
vim -p doc1 doc2 gt go through tabs :tabnew To open new tab
- Append a file:
:w >> ~/My-lousy-document
- Check spelllinng:
:setlocal spell spelllang=en_us :setlocal nospell ]s next word [s previous word z= word suggestions
- Spelling can be mapped to a key if used frequently enough, in my
~/.vimrcI mapped spelling the the F7 key:
map <F7> <Esc>:setlocal spell spelllang=en_us map <S-F7> <Esc>:setlocal nospell
- I like to alway have tabs so I put these in my
~/.bashrcto have tabs every time I open a file:
alias v="vim -p" alias sv="sudo vim -p"
My Terminal - Gush