1 " Vim main configuration file.
6 " Make sure Vim (and not Vi) settings are used.
9 " Load my scripts from ~/.vim (my scripts), ~/.vim/plugins (plugins) and
10 " ~/.vim/runtime (checkout of Vim runtime files).
11 set runtimepath-=~/.vim
12 set runtimepath^=~/.vim,~/.vim/plugins,~/.vim/runtime
14 " Disable modelines as they may cause security problems. Instead use
15 " securemodelines (Vim script #1876).
18 " When completing paths first use the longest path then display a list of all
20 set wildmode=longest,list
22 " Increase number of tabs which can be opened with the -p option.
30 " Enable automatic file detection, plugin and indention.
32 filetype plugin indent on
35 " Use UTF-8 file encoding for all files. Automatically recognize latin1 in
37 set fileencodings=utf-8,latin1
39 " Wrap text after 78 characters.
42 " Set tabs to 4 spaces, use softtabs.
46 " When < and > is used indent/deindent to the next shiftwidth boundary.
48 " Use the default value for real tabs.
51 " Enable auto indention.
54 " When joining lines only add one space after a sentence.
57 " Allow backspacing over autoindent and line breaks.
58 set backspace=indent,eol
60 " Start a comment when hitting enter after a commented line (r) and when using
61 " o or O around a commented line (o).
63 " Don't break a line if was already longer then 'textwidth' when insert mode
67 " Allow virtual editing (cursor can be positioned anywhere, even when there is
68 " no character) in visual block mode.
71 " Already display matches while typing the search command. This makes spotting
75 " Activate syntax folding.
79 set foldlevel=99 " no closed folds at default, 'foldenable' would disable
80 " folding which is not what I want
83 " Only check for case if the searched word contains a capital character.
87 " Activate spell checking, use English as default. Don't use spell checking
89 if v:version >= 700 && !&diff
94 " Allow buffers with changes to be hidden.
100 " Use a dark background.
103 " Activate lines display.
105 " Display the ruler with current line/file position.
107 " Display partial commands in the status line.
110 " Visualize the line the cursor is currently in.
115 " Display tabs, trailing space, non breakable spaces and long lines (when
116 " wrapping is enabled).
118 set listchars=trail:-,nbsp:!,extends:>
121 " MAPPINGS (except for plugins, see PLUGIN SETTINGS below)
123 " Use <space> to move down a page and - to move up one like in mutt.
124 nnoremap <Space> <C-f>
127 " Fast access to buffers.
128 nnoremap <Leader>1 :1b<CR>
129 nnoremap <Leader>2 :2b<CR>
130 nnoremap <Leader>3 :3b<CR>
131 nnoremap <Leader>4 :4b<CR>
132 nnoremap <Leader>5 :5b<CR>
133 nnoremap <Leader>6 :6b<CR>
134 nnoremap <Leader>7 :7b<CR>
135 nnoremap <Leader>8 :8b<CR>
136 nnoremap <Leader>9 :9b<CR>
137 nnoremap <Leader>0 :10b<CR>
139 " Maps to change spell language between English and German and disable it.
141 map <Leader>sn :set nospell<CR>
142 map <Leader>se :set spell spelllang=en_us<CR>
143 map <Leader>sd :set spell spelllang=de_de<CR>
146 " Add semicolon to the end of the line. Thanks to
147 " http://www.van-laarhoven.org/vim/.vimrc for this idea and godlygeek in #vim
148 " on Freenode for an improved version which doesn't clobber any marks.
149 nnoremap <silent> ; :call setline(line('.'), getline('.') . ';')<CR>
151 " I often type "W" instead of "w" when trying to save a file. Fix my mistake.
152 " Thanks to Tony Mechelynck <antoine.mechelynck@gmail.com> from the Vim
153 " mailing list for the commands.
160 \ ((getcmdtype() == ':' && getcmdpos() <= 2) ? 'w' : 'W')
161 cnoreabbrev <expr> Wq
162 \ ((getcmdtype() == ':' && getcmdpos() <= 3) ? 'wq' : 'Wq')
163 cnoreabbrev <expr> Wqa
164 \ ((getcmdtype() == ':' && getcmdpos() <= 4) ? 'wqa' : 'Wqa')
166 " Also fix my typo with "Q".
172 \ ((getcmdtype() == ':' && getcmdpos() <= 2) ? 'q' : 'Q')
173 cnoreabbrev <expr> Qa
174 \ ((getcmdtype() == ':' && getcmdpos() <= 3) ? 'qa' : 'Qa')
177 " Make sure xa0 (alt + space) is automatically changed to a normal whitespace
178 " if pressed accidentally while in insert mode (happens on Mac when alt
179 " doesn't send escape).
181 imap <Char-0xa0> <Space>
184 " Disable Apple style movements in MacVim.
185 if has('gui_macvim') && has('eval')
186 let macvim_skip_cmd_opt_movement = 1
192 " Activate syntax coloring.
196 " Highlight text longer then 78 characters. Thanks to Tony Mechelynck
197 " <antoine.mechelynck@gmail.com> from the Vim mailing list.
199 2match Todo /\%>78v./
204 " Highlight TODO, FIXME, CHANGED and XXX in all documents.
205 if v:version >= 701 && has('patch40')
206 call matchadd('Todo', '\(TODO\|FIXME\|CHANGED\|XXX\)')
213 " Settings for the NERD commenter.
214 " Don't create any mappings I don't want to use.
216 let NERDCreateDefaultMappings = 0
218 " Map toggle comment.
219 map <Leader><Leader> <plug>NERDCommenterToggle
224 " Use a custom auto group to prevent problems when the vimrc files is sourced
230 " Use diff filetype for mercurial patches in patch queue.
231 autocmd BufReadPost */.hg/patches/* set filetype=diff