1 " Vim main configuration file.
4 " Make sure Vim (and not Vi) settings are enabled.
7 " Load my scripts from ~/.vim (my scripts), ~/.vim/plugins (plugins) and
8 " ~/.vim/runtime (checkout of Vim runtime files).
9 set runtimepath-=~/.vim
10 set runtimepath^=~/.vim,~/.vim/plugins,~/.vim/runtime
15 " Enable automatic file detection, plugin and indention.
17 filetype plugin indent on
20 " Use UTF-8 file encoding for all files.
21 set fileencodings=utf-8
23 " Wrap text after 78 characters.
26 " Set tabs to 4 spaces, use softtabs.
30 " When < and > is used indent/deindent to the next shiftwidth boundary.
32 " Use the default value for real tabs.
35 " Enable auto indention.
38 " When joining lines only add one space after a sentence.
41 " Allow backspacing over autoindent and line breaks.
42 set backspace=indent,eol
44 " Start a comment when hitting enter after a commented line (r) and when using
45 " o or O around a commented line (o).
47 " Don't break a line if was already longer then 'textwidth' when insert mode
51 " Allow virtual editing (cursor can be positioned anywhere, even when there is
52 " no character) in visual block mode.
55 " Already display matches while typing the search command. This makes spotting
59 " Activate syntax folding.
63 set foldlevel=99 " no folding at default
66 " Only check for case if the searched word contains a capital character.
70 " Activate spell checking, use English as default.
79 " Use a dark background.
82 " Activate lines display.
84 " Display the ruler with current line/file position.
86 " Display partial commands in the status line.
89 " Visualize the line the cursor is currently in.
94 " Display tabs as "^I" and trailing space as "-".
101 " When completing paths first use the longest path then display a list of all
103 set wildmode=longest,list
105 " Increase number of tabs which can be opened with the -p option.
111 " MAPPINGS (except for plugins, see PLUGIN SETTINGS below)
113 " Use <space> to move down a page and - to move up one like in mutt.
114 nnoremap <Space> <C-f>
117 " Maps to change spell language between English and German.
118 map <Leader>se :set spelllang=en_us<CR>
119 map <Leader>sd :set spelllang=de_de<CR>
121 " Add semicolon to the end of the line. Thanks to
122 " http://www.van-laarhoven.org/vim/.vimrc for this idea and godlygeek in #vim
123 " for an improved version which doesn't clobber any marks.
124 nnoremap <silent> ; :call setline(line('.'), getline('.') . ';')<CR>
126 " I often type "W" instead of "w" when trying to save a file. Fix my mistake.
127 " Thanks to Tony Mechelynck <antoine.mechelynck@gmail.com> from the Vim
128 " mailing list for the commands.
135 \ ((getcmdtype() == ':' && getcmdpos() <= 2) ? 'w' : 'W')
136 cnoreabbrev <expr> Wq
137 \ ((getcmdtype() == ':' && getcmdpos() <= 3) ? 'wq' : 'Wq')
138 cnoreabbrev <expr> Wqa
139 \ ((getcmdtype() == ':' && getcmdpos() <= 4) ? 'wqa' : 'Wqa')
141 " Also fix my typo with "Q".
147 \ ((getcmdtype() == ':' && getcmdpos() <= 2) ? 'q' : 'Q')
148 cnoreabbrev <expr> Qa
149 \ ((getcmdtype() == ':' && getcmdpos() <= 3) ? 'qa' : 'Qa')
152 " Make sure xa0 (alt + space) is automatically changed to a normal whitespace
153 " if pressed accidentally while in insert mode (happens on Mac sometimes).
155 imap <Char-0xa0> <Space>
158 " Disable Apple style movements in MacVim.
159 if has("gui_macvim") && has("eval")
160 let macvim_skip_cmd_opt_movement = 1
166 " Activate syntax coloring.
170 " Highlight text longer then 78 characters. Thanks to Tony Mechelynck
171 " <antoine.mechelynck@gmail.com> from the Vim mailing list.
173 2match Todo /\%>78v./
182 " Settings for the NERD commenter.
183 " Don't create any mappings I don't want to use.
185 let NERDCreateDefaultMappings = 0
187 " Map toggle comment.
188 map <Leader><Leader> <plug>NERDCommenterToggle
193 " Use a custom auto group to prevent problems when the vimrc files is sourced
199 " Use diff filetype for mercurial patches in patch queue.
200 autocmd BufReadPost */.hg/patches/* set filetype=diff