]> git.rmz.io Git - dotfiles.git/blob - vimrc
fixes permissions on Skaro
[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 autocmd BufReadPost *
99 \ if line("'\"") > 1 && line("'\"") <= line("$") |
100 \ exe "normal! g`\"" |
101 \ endif
102
103 augroup END
104
105 else
106
107 set autoindent " always set autoindenting on
108
109 endif " has("autocmd")
110
111 " Convenient command to see the difference between the current buffer and the
112 " file it was loaded from, thus the changes you made.
113 " Only define it when not defined already.
114 if !exists(":DiffOrig")
115 command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
116 \ | wincmd p | diffthis
117 endif
118
119 " Ask what to do when closing unsaved documents
120 set confirm
121
122 " If using a dark background within the editing area and syntax highlighting
123 " turn on this option as well
124 set background=dark
125
126 " The following are commented out as they cause vim to behave a lot
127 " differently from regular Vi. They are highly recommended though.
128 set showcmd " Show (partial) command in status line.
129 set showmatch " Show matching brackets.
130 set ignorecase " Do case insensitive matching
131 set smartcase " Do smart case matching
132 set incsearch " Incremental search
133 set autowrite " Automatically save before commands like :next and :make
134 "set hidden " Hide buffers when they are abandoned
135 "set mouse=a " Enable mouse usage (all modes)
136
137 " expand tabs
138 set softtabstop=4
139 set shiftwidth=4
140 set expandtab
141
142 set showbreak=▒▒
143
144 set pastetoggle=<F11>
145 " split right when using :vsp
146 set splitright
147
148 set scrolloff=3 " keep at least 3 lines above/below
149 " Press i to enter insert mode, and ii to exit.
150 imap ii <Esc>
151 " Press `` to toggle insert and replace mode (no <Insert> key on Mac keyboard)
152 imap `` <Insert>
153
154 " Jump to the next or previous line that has the same level or a lower
155 " level of indentation than the current line.
156 "
157 " exclusive (bool): true: Motion is exclusive
158 " false: Motion is inclusive
159 " fwd (bool): true: Go to next line
160 " false: Go to previous line
161 " lowerlevel (bool): true: Go to line with lower indentation level
162 " false: Go to line with the same indentation level
163 " skipblanks (bool): true: Skip blank lines
164 " false: Don't skip blank lines
165 function! NextIndent(exclusive, fwd, lowerlevel, skipblanks)
166 let line = line('.')
167 let column = col('.')
168 let lastline = line('$')
169 let indent = indent(line)
170 let stepvalue = a:fwd ? 1 : -1
171 while (line > 0 && line <= lastline)
172 let line = line + stepvalue
173 if ( ! a:lowerlevel && indent(line) == indent ||
174 \ a:lowerlevel && indent(line) < indent)
175 if (! a:skipblanks || strlen(getline(line)) > 0)
176 if (a:exclusive)
177 let line = line - stepvalue
178 endif
179 exe line
180 exe "normal " column . "|"
181 return
182 endif
183 endif
184 endwhile
185 endfunction
186
187 " Moving back and forth between lines of same or lower indentation.
188 nnoremap <silent> [l :call NextIndent(0, 0, 0, 1)<CR>
189 nnoremap <silent> ]l :call NextIndent(0, 1, 0, 1)<CR>
190 nnoremap <silent> [L :call NextIndent(0, 0, 1, 1)<CR>
191 nnoremap <silent> ]L :call NextIndent(0, 1, 1, 1)<CR>
192 vnoremap <silent> [l <Esc>:call NextIndent(0, 0, 0, 1)<CR>m'gv''
193 vnoremap <silent> ]l <Esc>:call NextIndent(0, 1, 0, 1)<CR>m'gv''
194 vnoremap <silent> [L <Esc>:call NextIndent(0, 0, 1, 1)<CR>m'gv''
195 vnoremap <silent> ]L <Esc>:call NextIndent(0, 1, 1, 1)<CR>m'gv''
196 onoremap <silent> [l :call NextIndent(0, 0, 0, 1)<CR>
197 onoremap <silent> ]l :call NextIndent(0, 1, 0, 1)<CR>
198 onoremap <silent> [L :call NextIndent(1, 0, 1, 1)<CR>
199 onoremap <silent> ]L :call NextIndent(1, 1, 1, 1)<CR>
200 " end of jump indent