Home

Search this site:
 

Horshack’s
very
own site

 

This is Bavaria, Germany!
You will find links to Perl,
bootdisks for system administration,
a lot of Linux,
Windows administration
and some personal belongings.
Vim, useful keystrokes, .exrc, howto configure

Vim, useful keystrokes, .exrc, howto configure

~/.exrc, the startupfile of vim

.exrc may seem to be a strange startup-file for vim, but vim is a successor of vi, and vi is a successor of the editor called ex. Rc is the name of a startup-file, .exrc is the startup-file of ex.

Ok, what is useful in a startup-file when you are a Perl-programmer? Damian Conway tells about it in his book "Perl Best Practices". I stole a lot of good hints from this book. Here is what I think is good:

" preserve current indent on new lines
set autoindent
" make backspaces delete sensibly
set backspace=indent,eol,start
" indentation levels every four columns
set tabstop=4
" convert all tabs to space
set expandtab
" indent/outdent by four columns
set shiftwidth=4
" indent/outdent to nearest tabstops
set shiftround
" syntax hilighting in vim
syntax on

No backup-files

To avoid file like bla~ put this into your .vimrc

" no backup-files like bla~ 
set nobackup
set nowritebackup 

Change behaviour via commentlines

Tell vi that syntaxhilighting shall be for perl:
# t/001_loading.t
# vim:ft=perl
...

Useful keystrokes

jump to next letter u in line <commandmode> fu simply jump to the next letter u in the current line
visually copy lines <commandmode>V
(this is an upper V)
lines get hilighted, end command with y (=yank), d (=delete) and put everything out with p like always.
mark line and come back  ma marks this line with the letter a (works from a-z: fa, fb, fc...)
  'a jump to mark a
Marks are useful when you want to remember a place in a sourcefile you edit, look in another place for something and want to come back later
indent/outdent lines  :4,12>
:4,12>>
indent lines 4-12
indent lines 4-12 - two times
  :4,12< put the lines more left, not indent
Paste code :set paste Paste code without autoindent, autocomment

Books

Vi IMproved - Vim by Steve Oualline, published by New Riders

Impressum