]> ruderich.org/simon Gitweb - config/dotfiles.git/blob - vimrc
vimrc: Minor indentation fix.
[config/dotfiles.git] / vimrc
1 " Vim main configuration file.
2
3
4 " Make sure Vim (and not Vi) settings are enabled.
5 set nocompatible
6
7
8 " EDIT SETTINGS
9
10 " Enable automatic file detection, plugin and indention.
11 filetype plugin indent on
12
13 " Use UTF-8 file encoding for all files.
14 set fileencodings=utf-8
15
16 " Wrap text after 78 characters.
17 set textwidth=78
18
19 " Set tabs to 4 spaces, use softtabs.
20 set shiftwidth=4
21 set softtabstop=4
22 set expandtab
23 " When < and > is used indent/deindent to the next shiftwidth boundary.
24 set shiftround
25 " Use the default value for real tabs.
26 set tabstop=8
27
28 " Enable auto indention.
29 set autoindent
30
31 " When joining lines only add one space after a sentence.
32 set nojoinspaces
33
34 " Allow backspacing over autoindent and line breaks.
35 set backspace=indent,eol
36
37 " Start a comment when hitting enter after a commented line (r) and when using
38 " o or O around a commented line (o).
39 set formatoptions+=ro
40 " Don't break a line if was already longer then 'textwidth' when insert mode
41 " started.
42 set formatoptions+=l
43
44 " Allow virtual editing (cursor can be positioned anywhere, even when there is
45 " no character) in visual block mode.
46 set virtualedit=block
47
48 " Already display matches while typing the search command. This makes spotting
49 " errors easily.
50 set incsearch
51
52 " Activate syntax folding.
53 set foldmethod=syntax
54 set foldcolumn=2
55 set foldlevel=99 " no folding at default
56
57 " Only check for case if the searched word contains a capital character.
58 set ignorecase
59 set smartcase
60
61 " Activate spell checking, use English as default.
62 if v:version >= 700
63     set spell
64     set spelllang=en_us
65 endif
66
67
68 " DISPLAY SETTINGS
69
70 " Use a dark background.
71 set background=dark
72
73 " Activate lines display.
74 set number
75 " Display the ruler with current line/file position.
76 set ruler
77 " Display partial commands in the status line.
78 set showcmd
79
80 " Visualize the line the cursor is currently in.
81 if v:version >= 700
82     set cursorline
83 endif
84
85 " Display tabs as "^I" and trailing space as "-".
86 set list
87 set listchars=trail:-
88
89
90 " EDITOR SETTINGS
91
92 " When completing paths first use the longest path then display a list of all
93 " possible files.
94 set wildmode=longest,list
95
96 " Increase number of tabs which can be opened with the -p option.
97 if v:version >= 700
98     set tabpagemax=50
99 endif
100
101
102 " MAPPINGS (except for plugins, see PLUGIN SETTINGS below)
103
104 " Use "," as my mapleader.
105 let mapleader = ","
106 let maplocalleader = ","
107
108 " Use <space> to move down a page and - to move up one like in mutt.
109 nnoremap <Space> <C-f>
110 nnoremap - <C-b>
111
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>
115
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>
120
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.
124 if v:version < 700
125     cnoreabbrev W w
126     cnoreabbrev Wq wq
127 else
128     cnoreabbrev <expr> W
129         \ ((getcmdtype() == ':' && getcmdpos() <= 2) ? 'w' : 'W')
130     cnoreabbrev <expr> Wq
131         \ ((getcmdtype() == ':' && getcmdpos() <= 3) ? 'wq' : 'Wq')
132 endif
133 " Also fix my typo with "Q".
134 if v:version < 700
135     cnoreabbrev Q q
136 else
137     cnoreabbrev <expr> Q
138         \ ((getcmdtype() == ':' && getcmdpos() <= 2) ? 'q' : 'Q')
139 endif
140
141 " Make sure xa0 (alt + space) is automatically changed to a normal whitespace
142 " if pressed accidentally while in insert mode (happens on Mac sometimes).
143 if has("mac")
144     imap <Char-0xa0> <Space>
145 endif
146
147 " Disable Apple style movements in MacVim.
148 if has("gui_macvim")
149     let macvim_skip_cmd_opt_movement = 1
150 endif
151
152
153 " SYNTAX SETTINGS
154
155 " Activate syntax coloring.
156 if has("syntax")
157     syntax enable
158
159 " Highlight text longer then 78 characters. Thanks to Tony Mechelynck
160 " <antoine.mechelynck@gmail.com> from the Vim mailing list.
161     if v:version >= 700
162         2match Todo /\%>78v./
163     else
164         match Todo /\%>78v./
165     endif
166 endif
167
168
169 " PLUGIN SETTINGS
170
171 " Settings for the NERD commenter.
172 " Don't create any mappings I don't want to use.
173 let NERDCreateDefaultMappings = 0
174 " Map toggle comment.
175 map <Leader><Leader> <plug>NERDCommenterToggle
176
177
178 " AUTO COMMANDS
179
180 " Use a custom auto group to prevent problems when the vimrc files is sourced
181 " twice.
182 if has("autocmd")
183     augroup vimrc
184         autocmd!
185
186 " Use diff filetype for mercurial patches in patch queue.
187         autocmd BufReadPost */.hg/patches/* set filetype=diff
188
189     augroup END
190 endif