" EDITOR SETTINGS
+" Prevent editing as root as it may cause security problems. Use sudoedit
+" instead. Thanks to godlygeek in #vim on Freenode (2009-06-19 22:21).
+if $HOME == '/root' || exists('$SUDO_USER')
+ echomsg 'Running as root is forbidden! Use sudoedit.'
+ qa
+endif
+
+
+" Reset all options (except 'term, 'lines' and 'columns'). This makes sure a
+" system wide configuration file doesn't change default values.
+set all&
+
" Make sure Vim (and not Vi) settings are used.
set nocompatible
" Display line numbers.
set number
-" Display the ruler with current line/file position.
+" Display the ruler with current line/file position. If 'statusline' is used
+" then this only affects <C-g>.
set ruler
" Display partial commands in the status line.
set showcmd
set listchars+=nbsp:!
endif
-" Always display the status line even if there is only one window.
if has('statusline')
+ " Always display the status line even if there is only one window.
set laststatus=2
+
+ set statusline=
+ " on the left
+ set statusline+=%02n: " buffer number
+ set statusline+=%f\ " path to current file in buffer
+ set statusline+=%h " [help] if buffer is help file
+ set statusline+=%w " [Preview] if buffer is preview buffer
+ set statusline+=%m " [+] if buffer was modified,
+ " [-] if 'modifiable' is off
+ set statusline+=%r " [RO] if buffer is read only
+
+ " on the right
+ set statusline+=%= " right align
+ set statusline+=%-12.(%l,%c%V%)\ " line number (%l),
+ " column number (%c),
+ " virtual column number if different
+ " than %c (%V)
+ set statusline+=%P " position in file in percent
endif
" But not for Git commits, go to beginning of the file.
autocmd BufReadPost COMMIT_EDITMSG normal! gg
+" Make sure 'list' and 'number' is disabled in help files. This is necessary
+" when switching to a help buffer which is in the background with :buffer as
+" these options are local to windows (and not only to buffers). This happens
+" because I often want to use only one window and thus the help buffer is in
+" the background.
+ autocmd BufWinEnter *.txt
+ \ if &filetype == 'help' |
+ \ setlocal nolist |
+ \ setlocal nonumber |
+ \ endif
+
" AFTER/FTPLUGIN AUTO COMMANDS
" Disable spell checking for files which don't need it.