1 " Vim main configuration file.
6 " Make sure Vim (and not Vi) settings are enabled.
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 " When completing paths first use the longest path then display a list of all
16 set wildmode=longest,list
18 " Increase number of tabs which can be opened with the -p option.
26 " Enable automatic file detection, plugin and indention.
28 filetype plugin indent on
31 " Use UTF-8 file encoding for all files.
32 set fileencodings=utf-8
34 " Wrap text after 78 characters.
37 " Set tabs to 4 spaces, use softtabs.
41 " When < and > is used indent/deindent to the next shiftwidth boundary.
43 " Use the default value for real tabs.
46 " Enable auto indention.
49 " When joining lines only add one space after a sentence.
52 " Allow backspacing over autoindent and line breaks.
53 set backspace=indent,eol
55 " Start a comment when hitting enter after a commented line (r) and when using
56 " o or O around a commented line (o).
58 " Don't break a line if was already longer then 'textwidth' when insert mode
62 " Allow virtual editing (cursor can be positioned anywhere, even when there is
63 " no character) in visual block mode.
66 " Already display matches while typing the search command. This makes spotting
70 " Activate syntax folding.
74 set foldlevel=99 " no closed folds at default, 'foldenable' would disable
75 " folding which is not what I want
78 " Only check for case if the searched word contains a capital character.
82 " Activate spell checking, use English as default.
88 " Allow buffers with changes to be hidden.
94 " Use a dark background.
97 " Activate lines display.
99 " Display the ruler with current line/file position.
101 " Display partial commands in the status line.
104 " Visualize the line the cursor is currently in.
109 " Display tabs as "^I" and trailing space as "-".
111 set listchars=trail:-
114 " MAPPINGS (except for plugins, see PLUGIN SETTINGS below)
116 " Use <space> to move down a page and - to move up one like in mutt.
117 nnoremap <Space> <C-f>
120 " Maps to change spell language between English and German and disable it.
121 map <Leader>sn :set nospell<CR>
122 map <Leader>se :set spell spelllang=en_us<CR>
123 map <Leader>sd :set spell spelllang=de_de<CR>
125 " Add semicolon to the end of the line. Thanks to
126 " http://www.van-laarhoven.org/vim/.vimrc for this idea and godlygeek in #vim
127 " on Freenode for an improved version which doesn't clobber any marks.
128 nnoremap <silent> ; :call setline(line('.'), getline('.') . ';')<CR>
130 " I often type "W" instead of "w" when trying to save a file. Fix my mistake.
131 " Thanks to Tony Mechelynck <antoine.mechelynck@gmail.com> from the Vim
132 " mailing list for the commands.
139 \ ((getcmdtype() == ':' && getcmdpos() <= 2) ? 'w' : 'W')
140 cnoreabbrev <expr> Wq
141 \ ((getcmdtype() == ':' && getcmdpos() <= 3) ? 'wq' : 'Wq')
142 cnoreabbrev <expr> Wqa
143 \ ((getcmdtype() == ':' && getcmdpos() <= 4) ? 'wqa' : 'Wqa')
145 " Also fix my typo with "Q".
151 \ ((getcmdtype() == ':' && getcmdpos() <= 2) ? 'q' : 'Q')
152 cnoreabbrev <expr> Qa
153 \ ((getcmdtype() == ':' && getcmdpos() <= 3) ? 'qa' : 'Qa')
156 " Make sure xa0 (alt + space) is automatically changed to a normal whitespace
157 " if pressed accidentally while in insert mode (happens on Mac sometimes).
159 imap <Char-0xa0> <Space>
162 " Disable Apple style movements in MacVim.
163 if has("gui_macvim") && has("eval")
164 let macvim_skip_cmd_opt_movement = 1
170 " Activate syntax coloring.
174 " Highlight text longer then 78 characters. Thanks to Tony Mechelynck
175 " <antoine.mechelynck@gmail.com> from the Vim mailing list.
177 2match Todo /\%>78v./
186 " Settings for the NERD commenter.
187 " Don't create any mappings I don't want to use.
189 let NERDCreateDefaultMappings = 0
191 " Map toggle comment.
192 map <Leader><Leader> <plug>NERDCommenterToggle
197 " Use a custom auto group to prevent problems when the vimrc files is sourced
203 " Use diff filetype for mercurial patches in patch queue.
204 autocmd BufReadPost */.hg/patches/* set filetype=diff