1 " Vimrc file, http://phuzz.org
2
3 set nocompatible " use vim defaults
4 set ls=2 " allways show status line
5 set tabstop=4 " numbers of spaces of tab character
6 set shiftwidth=4 " numbers of spaces to (auto)indent
7 set scrolloff=3 " keep 3 lines when scrolling
8 set showcmd " display incomplete commands
9 set hlsearch " highlight searches
10 set incsearch " do incremental searching
11 set ruler " show the cursor position all the time
12 set visualbell t_vb= " turn off error beep/flash
13 set novisualbell " turn off visual bell
14 set nobackup " do not keep a backup file
15 set number " show line numbers
16 set ignorecase " ignore case when searching
17 "set noignorecase " don't ignore case
18 set title " show title in console title bar
19 set ttyfast " smoother changes
20 "set ttyscroll=0 " turn off scrolling, didn't work well with PuTTY
21 set modeline " last lines in document sets vim mode
22 set modelines=3 " number lines checked for modelines
23 set shortmess=atI " Abbreviate messages
24 set nostartofline " don't jump to first character when paging
25 set whichwrap=b,s,h,l,<,>,[,] " move freely between files
26 "set viminfo='20,<50,s10,h
27
28 "set autoindent " always set autoindenting on
29 "set smartindent " smart indent
30 "set cindent " cindent
31 set noautoindent
32 set nosmartindent
33 set nocindent
34
35 "set autowrite " auto saves changes when quitting and swiching buffer
36 "set expandtab " tabs are converted to spaces, use only when required
37 "set sm " show matching braces, somewhat annoying...
38 "set nowrap " don't wrap lines
39
40 syntax on " syntax highlighing
41 if has("gui_running")
42 " See ~/.gvimrc
43 set guifont=Monospace\ 10 " use this font
44 set lines=50 " height = 50 lines
45 set columns=100 " width = 100 columns
46 set background=light " adapt colors for background
47 set selectmode=mouse,key,cmd
48 set keymodel=
49 else
50 colorscheme elflord " use this color scheme
51 set background=dark " adapt colors for background
52 endif
53
54 if has("autocmd")
55 " Restore cursor position
56 au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif
57
58 " Filetypes (au = autocmd)
59 au FileType helpfile set nonumber " no line numbers when viewing help
60 au FileType helpfile nnoremap <buffer><cr> <c-]> " Enter selects subject
61 au FileType helpfile nnoremap <buffer><bs> <c-T> " Backspace to go back
62
63 " When using mutt, text width=72
64 au FileType mail,tex set textwidth=72
65 "au FileType cpp,c,java,sh,pl,php,phtml,asp set autoindent
66 au FileType cpp,c,java,sh,pl,php,phtml,asp,xml,javascript set smartindent
67 nnoremap <C-p> :set invpaste paste?<CR>
68 set pastetoggle=<C-p>
69 set showmode
70 "au FileType cpp,c,java,sh,pl,php,phtml,asp set cindent
71 "au BufRead mutt*[0-9] set tw=72
72
73 " Automatically chmod +x Shell and Perl scripts
74 "au BufWritePost *.sh !chmod +x %
75 "au BufWritePost *.pl !chmod +x %
76
77 " File formats
78 au BufNewFile,BufRead *.phtml set syntax=php
79 au BufNewFile,BufRead *.pls set syntax=dosini
80 au BufNewFile,BufRead modprobe.conf set syntax=modconf
81
82 " Ctrl+X O
83 autocmd FileType python set omnifunc=pythoncomplete#Complete
84 autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
85 autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
86 autocmd FileType css set omnifunc=csscomplete#CompleteCSS
87 autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
88 autocmd FileType php set omnifunc=phpcomplete#CompletePHP
89 autocmd FileType c set omnifunc=ccomplete#Complete
90
91 autocmd FileType php noremap <C-L> :!php -l %<CR>
92 autocmd Filetype html,xml,xsl source ~/.vim/closetag.vim
93 endif
94
95 " Keyboard mappings
96 map <F1> :previous<CR> " map F1 to open previous buffer
97 map <F2> :next<CR> " map F2 to open next buffer
98 map <silent> <C-N> :silent noh<CR> " turn off highlighted search
99 map ,v :sp ~/.vimrc<cr> " edit my .vimrc file in a split
100 map ,e :e ~/.vimrc<cr> " edit my .vimrc file
101 map ,u :source ~/.vimrc<cr> " update the system settings from my vimrc file
102 "----- write out html file
103 map ,h :source $VIM/vim70/syntax/2html.vim<cr>:w<cr>:clo<cr>
104
105
106 " Common command line typos
107 "cmap W w
108 "cmap Q q
109
110 " Keyboard mapping for numeric keypad
111 imap <Esc>OM <c-m>
112 map <Esc>OM <c-m>
113 imap <Esc>OP <nop>
114 map <Esc>OP <nop>
115 imap <Esc>OQ /
116 map <Esc>OQ /
117 imap <Esc>OR *
118 map <Esc>OR *
119 imap <Esc>OS -
120 map <Esc>OS -
121
122 imap <Esc>Ol +
123 imap <Esc>Om -
124 imap <Esc>On ,
125 imap <Esc>Op 0
126 imap <Esc>Oq 1
127 imap <Esc>Or 2
128 imap <Esc>Os 3
129 imap <Esc>Ot 4
130 imap <Esc>Ou 5
131 imap <Esc>Ov 6
132 imap <Esc>Ow 7
133 imap <Esc>Ox 8
134 imap <Esc>Oy 9
135 imap <Esc>Oz 0