]> git.rmz.io Git - dotfiles.git/blob - vimrc
remove (year)(quality)[lang] when setting the title
[dotfiles.git] / vimrc
1 " An example for a vimrc file.
2 "
3 " Maintainer: Bram Moolenaar <Bram@vim.org>
4 " Last change: 2008 Dec 17
5 "
6 " To use it, copy it to
7 " for Unix and OS/2: ~/.vimrc
8 " for Amiga: s:.vimrc
9 " for MS-DOS and Win32: $VIM\_vimrc
10 " for OpenVMS: sys$login:.vimrc
11
12 " When started as "evim", evim.vim will already have done these settings.
13 if v:progname =~? "evim"
14 finish
15 endif
16
17 " TODO
18 " organize this file, never thought it'll get this big
19 " TODO
20
21 " pathogen.vim runtime path manipulation
22 silent! call pathogen#infect()
23
24 " Use Vim settings, rather than Vi settings (much better!).
25 " This must be first, because it changes other options as a side effect.
26 set nocompatible
27
28 " allow backspacing over everything in insert mode
29 set backspace=indent,eol,start
30
31 if has("vms")
32 set nobackup " do not keep a backup file, use versions instead
33 else
34 set backup " keep a backup file
35 set backupdir=$HOME/.vim/backupdir
36 endif
37 set history=50 " keep 50 lines of command line history
38 set ruler " show the cursor position all the time
39 set showcmd " display incomplete commands
40 set incsearch " do incremental searching
41 set number " show some linenumbers
42
43 " For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
44 " let &guioptions = substitute(&guioptions, "t", "", "g")
45
46 " Don't use Ex mode, use Q for formatting
47 map Q gq
48
49 " CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
50 " so that you can undo CTRL-U after inserting a line break.
51 inoremap <C-U> <C-G>u<C-U>
52
53 "paste toggle
54 nmap <F11> :set paste! paste?<CR>
55 imap <F11> <C-o>:set paste!<CR>
56 vmap <F11> <Esc>:set paste!<CR>gv
57 set pastetoggle=<F11>
58
59 " In many terminal emulators the mouse works just fine, thus enable it.
60 "if has('mouse')
61 " "xterm mouse with middleclick paste
62 " nnoremap <MiddleMouse> i<MiddleMouse>
63 " vnoremap <MiddleMouse> s<MiddleMouse>
64 " set mouse=rnv
65 " "choose either one
66 " set ttymouse=xterm
67 " "set ttymouse=xterm2
68 "endif
69
70 " Switch syntax highlighting on, when the terminal has colors
71 " Also switch on highlighting the last used search pattern.
72 if &t_Co > 2 || has("gui_running")
73 syntax on
74 set hlsearch
75 endif
76
77 " Only do this part when compiled with support for autocommands.
78 if has("autocmd")
79
80 " Enable file type detection.
81 " Use the default filetype settings, so that mail gets 'tw' set to 72,
82 " 'cindent' is on in C files, etc.
83 " Also load indent files, to automatically do language-dependent indenting.
84 filetype plugin indent on
85
86 " Put these in an autocmd group, so that we can delete them easily.
87 augroup vimrcEx
88 au!
89
90 " For all text files set 'textwidth' to 78 characters.
91 autocmd FileType text setlocal textwidth=78
92
93 " When editing a file, always jump to the last known cursor position.
94 " Don't do it when the position is invalid or when inside an event handler
95 " (happens when dropping a file on gvim).
96 " Also don't do it when the mark is in the first line, that is the default
97 " position when opening a file.
98 " blacklist certain filetype, you can get a file type with :echo &ft
99 let blacklist = ['gitcommit']
100 autocmd BufReadPost *
101 \ if index(blacklist, &ft) < 0 && line("'\"") > 1 && line("'\"") <= line("$") |
102 \ exe "normal! g`\"" |
103 \ endif
104
105 augroup END
106
107 else
108
109 set autoindent " always set autoindenting on
110
111 endif " has("autocmd")
112
113 " Convenient command to see the difference between the current buffer and the
114 " file it was loaded from, thus the changes you made.
115 " Only define it when not defined already.
116 if !exists(":DiffOrig")
117 command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
118 \ | wincmd p | diffthis
119 endif
120
121 " Ask what to do when closing unsaved documents
122 set confirm
123
124 " If using a dark background within the editing area and syntax highlighting
125 " turn on this option as well
126 set background=dark
127
128 " The following are commented out as they cause vim to behave a lot
129 " differently from regular Vi. They are highly recommended though.
130 set showcmd " Show (partial) command in status line.
131 set showmatch " Show matching brackets.
132 set ignorecase " Do case insensitive matching
133 set smartcase " Do smart case matching
134 set incsearch " Incremental search
135 set autowrite " Automatically save before commands like :next and :make
136 "set hidden " Hide buffers when they are abandoned
137 "set mouse=a " Enable mouse usage (all modes)
138
139 " expand tabs
140 set softtabstop=4
141 set shiftwidth=4
142 set expandtab
143
144 set showbreak=▒▒
145
146 set pastetoggle=<F11>
147 " split right when using :vsp
148 set splitright
149
150 set scrolloff=3 " keep at least 3 lines above/below
151 " Press i to enter insert mode, and ii to exit.
152 imap ii <Esc>
153 " Press `` to toggle insert and replace mode (no <Insert> key on Mac keyboard)
154 imap `` <Insert>
155
156 " Jump to the next or previous line that has the same level or a lower
157 " level of indentation than the current line.
158 "
159 " exclusive (bool): true: Motion is exclusive
160 " false: Motion is inclusive
161 " fwd (bool): true: Go to next line
162 " false: Go to previous line
163 " lowerlevel (bool): true: Go to line with lower indentation level
164 " false: Go to line with the same indentation level
165 " skipblanks (bool): true: Skip blank lines
166 " false: Don't skip blank lines
167 function! NextIndent(exclusive, fwd, lowerlevel, skipblanks)
168 let line = line('.')
169 let column = col('.')
170 let lastline = line('$')
171 let indent = indent(line)
172 let stepvalue = a:fwd ? 1 : -1
173 while (line > 0 && line <= lastline)
174 let line = line + stepvalue
175 if ( ! a:lowerlevel && indent(line) == indent ||
176 \ a:lowerlevel && indent(line) < indent)
177 if (! a:skipblanks || strlen(getline(line)) > 0)
178 if (a:exclusive)
179 let line = line - stepvalue
180 endif
181 exe line
182 exe "normal " column . "|"
183 return
184 endif
185 endif
186 endwhile
187 endfunction
188
189 " Moving back and forth between lines of same or lower indentation.
190 nnoremap <silent> [l :call NextIndent(0, 0, 0, 1)<CR>
191 nnoremap <silent> ]l :call NextIndent(0, 1, 0, 1)<CR>
192 nnoremap <silent> [L :call NextIndent(0, 0, 1, 1)<CR>
193 nnoremap <silent> ]L :call NextIndent(0, 1, 1, 1)<CR>
194 vnoremap <silent> [l <Esc>:call NextIndent(0, 0, 0, 1)<CR>m'gv''
195 vnoremap <silent> ]l <Esc>:call NextIndent(0, 1, 0, 1)<CR>m'gv''
196 vnoremap <silent> [L <Esc>:call NextIndent(0, 0, 1, 1)<CR>m'gv''
197 vnoremap <silent> ]L <Esc>:call NextIndent(0, 1, 1, 1)<CR>m'gv''
198 onoremap <silent> [l :call NextIndent(0, 0, 0, 1)<CR>
199 onoremap <silent> ]l :call NextIndent(0, 1, 0, 1)<CR>
200 onoremap <silent> [L :call NextIndent(1, 0, 1, 1)<CR>
201 onoremap <silent> ]L :call NextIndent(1, 1, 1, 1)<CR>
202 " end of jump indent