1 " Vim main configuration file.
4 " Make sure Vim (and not Vi) settings are enabled.
10 " Enable automatic file detection, plugin and indention.
11 filetype plugin indent on
13 " Use UTF-8 file encoding for all files.
14 set fileencodings=utf-8
16 " Wrap text after 78 characters.
19 " Set tabs to 4 spaces, use softtabs.
23 " When < and > is used indent/deindent to the next shiftwidth boundary.
25 " Use the default value for real tabs.
28 " Enable auto indention.
31 " When joining lines only add one space after a sentence.
34 " Allow backspacing over autoindent and line breaks.
35 set backspace=indent,eol
37 " Start a comment when hitting enter after a commented line (r) and when using
38 " o or O around a commented line (o).
40 " Don't break a line if was already longer then 'textwidth' when insert mode
44 " Allow virtual editing (cursor can be positioned anywhere, even when there is
45 " no character) in visual block mode.
48 " Already display matches while typing the search command. This makes spotting
52 " Activate syntax folding.
55 set foldlevel=99 " no folding at default
57 " Only check for case if the searched word contains a capital character.
61 " Activate spell checking, use English as default.
70 " Use a dark background.
73 " Activate lines display.
75 " Display the ruler with current line/file position.
77 " Display partial commands in the status line.
80 " Visualize the line the cursor is currently in.
85 " Display tabs as "^I" and trailing space as "-".
92 " Don't use any modelines.
95 " When completing paths first use the longest path then display a list of all
97 set wildmode=longest,list
99 " Increase number of tabs which can be opened with the -p option.
105 " MAPPINGS (except for plugins, see PLUGIN SETTINGS below)
107 " Use "," as my mapleader.
109 let maplocalleader = ","
111 " Use <space> to move down a page and - to move up one like in mutt.
112 nnoremap <Space> <C-f>
115 " Maps to change spell language between English and German.
116 map <Leader>se :set spelllang=en_us<CR>
117 map <Leader>sd :set spelllang=de_de<CR>
119 " I often type "W" instead of "w" when trying to save a file. Fix my mistake.
120 " Thanks to Tony Mechelynck <antoine.mechelynck@gmail.com> from the Vim
121 " mailing list for the commands.
127 \ ((getcmdtype() == ':' && getcmdpos() <= 2) ? 'w' : 'W')
128 cnoreabbrev <expr> Wq
129 \ ((getcmdtype() == ':' && getcmdpos() <= 3) ? 'wq' : 'Wq')
131 " Also fix my typo with "Q".
136 \ ((getcmdtype() == ':' && getcmdpos() <= 2) ? 'q' : 'Q')
139 " Make sure xa0 (alt + space) is automatically changed to a normal whitespace
140 " if pressed accidentally while in insert mode (happens on Mac sometimes).
142 imap <Char-0xa0> <Space>
145 " Disable Apple style movements in MacVim.
147 let macvim_skip_cmd_opt_movement = 1
153 " Activate syntax coloring.
156 " Highlight text longer then 78 characters. Thanks to Tony Mechelynck
157 " <antoine.mechelynck@gmail.com> from the Vim mailing list.
159 2match Todo /\%>78v./
167 " Settings for the NERD commenter.
168 " Don't create any mappings I don't want to use.
169 let NERDCreateDefaultMappings = 0
170 " Map toggle comment.
171 map <Leader><Leader> <plug>NERDCommenterToggle
174 " Automatically save and the load the file state (stored in ~/.vim/view).
175 autocmd BufWrite * mkview
176 autocmd BufRead * loadview