1 " Vim main configuration file.
4 " Make sure Vim (and not Vi) settings are enabled.
10 " Enable automatic file detection, plugin and indention.
12 filetype plugin indent on
15 " Use UTF-8 file encoding for all files.
16 set fileencodings=utf-8
18 " Wrap text after 78 characters.
21 " Set tabs to 4 spaces, use softtabs.
25 " When < and > is used indent/deindent to the next shiftwidth boundary.
27 " Use the default value for real tabs.
30 " Enable auto indention.
33 " When joining lines only add one space after a sentence.
36 " Allow backspacing over autoindent and line breaks.
37 set backspace=indent,eol
39 " Start a comment when hitting enter after a commented line (r) and when using
40 " o or O around a commented line (o).
42 " Don't break a line if was already longer then 'textwidth' when insert mode
46 " Allow virtual editing (cursor can be positioned anywhere, even when there is
47 " no character) in visual block mode.
50 " Already display matches while typing the search command. This makes spotting
54 " Activate syntax folding.
58 set foldlevel=99 " no folding at default
61 " Only check for case if the searched word contains a capital character.
65 " Activate spell checking, use English as default.
74 " Use a dark background.
77 " Activate lines display.
79 " Display the ruler with current line/file position.
81 " Display partial commands in the status line.
84 " Visualize the line the cursor is currently in.
89 " Display tabs as "^I" and trailing space as "-".
96 " When completing paths first use the longest path then display a list of all
98 set wildmode=longest,list
100 " Increase number of tabs which can be opened with the -p option.
106 " MAPPINGS (except for plugins, see PLUGIN SETTINGS below)
108 " Use <space> to move down a page and - to move up one like in mutt.
109 nnoremap <Space> <C-f>
112 " Maps to change spell language between English and German.
113 map <Leader>se :set spelllang=en_us<CR>
114 map <Leader>sd :set spelllang=de_de<CR>
116 " Add semicolon to the end of the line. Thanks to
117 " http://www.van-laarhoven.org/vim/.vimrc for this idea and godlygeek in #vim
118 " for an improved version which doesn't clobber any marks.
119 nnoremap <silent> ; :call setline(line('.'), getline('.') . ';')<CR>
121 " I often type "W" instead of "w" when trying to save a file. Fix my mistake.
122 " Thanks to Tony Mechelynck <antoine.mechelynck@gmail.com> from the Vim
123 " mailing list for the commands.
130 \ ((getcmdtype() == ':' && getcmdpos() <= 2) ? 'w' : 'W')
131 cnoreabbrev <expr> Wq
132 \ ((getcmdtype() == ':' && getcmdpos() <= 3) ? 'wq' : 'Wq')
133 cnoreabbrev <expr> Wqa
134 \ ((getcmdtype() == ':' && getcmdpos() <= 4) ? 'wqa' : 'Wqa')
136 " Also fix my typo with "Q".
142 \ ((getcmdtype() == ':' && getcmdpos() <= 2) ? 'q' : 'Q')
143 cnoreabbrev <expr> Qa
144 \ ((getcmdtype() == ':' && getcmdpos() <= 3) ? 'qa' : 'Qa')
147 " Make sure xa0 (alt + space) is automatically changed to a normal whitespace
148 " if pressed accidentally while in insert mode (happens on Mac sometimes).
150 imap <Char-0xa0> <Space>
153 " Disable Apple style movements in MacVim.
154 if has("gui_macvim") && has("eval")
155 let macvim_skip_cmd_opt_movement = 1
161 " Activate syntax coloring.
165 " Highlight text longer then 78 characters. Thanks to Tony Mechelynck
166 " <antoine.mechelynck@gmail.com> from the Vim mailing list.
168 2match Todo /\%>78v./
177 " Settings for the NERD commenter.
178 " Don't create any mappings I don't want to use.
180 let NERDCreateDefaultMappings = 0
182 " Map toggle comment.
183 map <Leader><Leader> <plug>NERDCommenterToggle
188 " Use a custom auto group to prevent problems when the vimrc files is sourced
194 " Use diff filetype for mercurial patches in patch queue.
195 autocmd BufReadPost */.hg/patches/* set filetype=diff