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