Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 244 lines (194 sloc) 6.855 kb
8566761 @git2samus clarity
authored
1 " vim behavior "
2
1395f82 @git2samus update vim settings
authored
3 " plugin manager
4 execute pathogen#infect()
5
80bb338 @git2samus initial commit
authored
6 " disable vi compatibility
7 set nocompatible
8 " allow to change buffers without saving them
9 set hidden
10 " enable inline ft settings
11 set modeline
12
595dfe5 @git2samus improving tempfiles administration
authored
13 " http://weevilgenius.net/2010/10/vim-tip-relocating-vim-swapfiles/
1a0401e @git2samus vimrc cleanup
authored
14 set dir^=~/.vim/swp//
80bb338 @git2samus initial commit
authored
15
16 " enable syntax highlight
17 syntax on
18 " enable filetype-specific features
19 filetype plugin indent on
0991081 @git2samus don't mess with the colors
authored
20
09e302f @git2samus extend vim path from commandline
authored
21 " configure vim's path from env vars
22 let &path = &path . "," . substitute($VIMPATH, ':', ',', 'g')
23
8566761 @git2samus clarity
authored
24 " autofold
25 set foldmethod=indent
4fd7240 @git2samus expand folds automatically when opening files
authored
26 " expand folds when opening files
e881e5a @git2samus update fold-indent behavior
authored
27 au BufRead * normal zR
db6367d @git2samus updates
authored
28 " extras for vim-latexsuite
29 set grepprg=grep\ -nH\ $*
30 let g:tex_flavor='latex'
80bb338 @git2samus initial commit
authored
31
1395f82 @git2samus update vim settings
authored
32 " disable mouse by default
33 set mouse=
80bb338 @git2samus initial commit
authored
34 " enable/disable mouse support
e081bd2 @git2samus http://learnvimscriptthehardway.stevelosh.com/chapters/05.html
authored
35 nnoremap <silent> <Leader>m :silent set mouse=a<CR>:set mouse?<CR>
36 nnoremap <silent> <Leader>M :silent set mouse=<CR>:set mouse?<CR>
f65ae02 @git2samus fix and changing key for checktime
authored
37 " shortcut to check for external modifications
e081bd2 @git2samus http://learnvimscriptthehardway.stevelosh.com/chapters/05.html
authored
38 nnoremap <silent> <Leader><CR> :checktime<CR>
80bb338 @git2samus initial commit
authored
39
40
8566761 @git2samus clarity
authored
41 " avoid messing with the screen
42 set nowrap
43 " switch line wrap
e081bd2 @git2samus http://learnvimscriptthehardway.stevelosh.com/chapters/05.html
authored
44 nnoremap <silent> <Leader>w :silent set wrap!<CR>:set wrap?<CR>
4f90068 @git2samus try to write shorter lines
authored
45 " highlight expected code width
1bd7bf7 @git2samus colorcolumn shortcuts
authored
46 "set colorcolumn=80
47 " switch width marker
48 nnoremap <silent> <Leader>c :silent set colorcolumn=80<CR>:set colorcolumn?<CR>
49 nnoremap <silent> <Leader>C :silent set colorcolumn=<CR>:set colorcolumn?<CR>
8566761 @git2samus clarity
authored
50
51 " keep some context when moving
52 set scrolloff=1
53 set sidescrolloff=5
54
99d3e82 @git2samus move freely
authored
55 " move freely
56 set virtualedit=all
57
8566761 @git2samus clarity
authored
58
59 " enable search highlighting
60 set hlsearch
61 " enable incremental search
62 set incsearch
63 " case-sensitive search
64 set noignorecase
65 set nosmartcase
66
67 " swap search highlight
e081bd2 @git2samus http://learnvimscriptthehardway.stevelosh.com/chapters/05.html
authored
68 nnoremap <silent> <Leader><Leader> :nohlsearch<CR>
69 nnoremap <silent> <Leader>h :silent set hlsearch!<CR>:set hlsearch?<CR>
8566761 @git2samus clarity
authored
70 " swap case-insensitive search
e081bd2 @git2samus http://learnvimscriptthehardway.stevelosh.com/chapters/05.html
authored
71 nnoremap <silent> <Leader>i :silent set ignorecase!<CR>:set ignorecase?<CR>
8566761 @git2samus clarity
authored
72
73
74 " clipboard "
75
76 " use system registry by default
77 set clipboard=unnamed
1c98093 @git2samus adding alternate mapping for :set paste
authored
78 " alternate mapping using Leader for when <F12> is unavailable
e081bd2 @git2samus http://learnvimscriptthehardway.stevelosh.com/chapters/05.html
authored
79 nnoremap <silent> <Leader>p :silent set paste!<CR>
8566761 @git2samus clarity
authored
80
81
82 " appearance "
83
84 " readable colors on dark background
85 colorscheme desert
86
80bb338 @git2samus initial commit
authored
87 " enable statusbar
88 set laststatus=2
cdc2ab9 @git2samus disabling installation-specific feature (TODO make conditional)
authored
89 set statusline=%<%f\ %{&paste?'(p)\ ':''}%h%m%r%=%-14.(%l,%c%V%)\ %P
80bb338 @git2samus initial commit
authored
90 " enable wildmenu for tab-completion
91 set wildmenu
9d79c52 @git2samus change wildmode
authored
92 " show all matches, complete longest
93 set wildmode=list:longest
1a0401e @git2samus vimrc cleanup
authored
94 " avoid to open python bytecode
1395f82 @git2samus update vim settings
authored
95 set wildignore=*.swp,*.py[co],*.class,*.beam
80bb338 @git2samus initial commit
authored
96
97 " show line numbers in statusbar
98 set ruler
99 " show line numbers on the side
100 set number
101 " swap line numbering
e081bd2 @git2samus http://learnvimscriptthehardway.stevelosh.com/chapters/05.html
authored
102 nnoremap <silent> <Leader>n :silent set number!<CR>
80bb338 @git2samus initial commit
authored
103
104 " line bookmarks
105 sign define bookmark text=@
e081bd2 @git2samus http://learnvimscriptthehardway.stevelosh.com/chapters/05.html
authored
106 nnoremap <silent> <Leader>b :exe ":sign place " . line(".") . " name=bookmark line=" . line(".") . " file=" . expand("%:p")<CR>
4a9ee9d @git2samus resolve shortcut conflict
authored
107 nnoremap <silent> <Leader>B :sign unplace<CR>
108 nnoremap <silent> <Leader>* :sign unplace *<CR>
80bb338 @git2samus initial commit
authored
109
110
8566761 @git2samus clarity
authored
111 " whitespace and indentation "
80bb338 @git2samus initial commit
authored
112
8566761 @git2samus clarity
authored
113 " allow backspacing over everything in insert-mode
80bb338 @git2samus initial commit
authored
114 set backspace=indent,eol,start
115 " insert spaces by default
116 set expandtab
117
1a0401e @git2samus vimrc cleanup
authored
118 " show tabs, trailing spaces and other stuff
80bb338 @git2samus initial commit
authored
119 set list
1a0401e @git2samus vimrc cleanup
authored
120 " avoid unicode to prevent issues with PuTTY
8da02af @git2samus removing unicode chars
authored
121 set listchars=tab:-\ ,trail:_,precedes:<,extends:>
80bb338 @git2samus initial commit
authored
122
8566761 @git2samus clarity
authored
123 " remove trailing spaces on the current line
e081bd2 @git2samus http://learnvimscriptthehardway.stevelosh.com/chapters/05.html
authored
124 nnoremap <silent> <Leader>s :silent s/\s\+$<CR>
8566761 @git2samus clarity
authored
125 " remove trailing spaces on entire buffer without altering the cursor position
126 " TODO avoid changing the search pattern and highlighting
e081bd2 @git2samus http://learnvimscriptthehardway.stevelosh.com/chapters/05.html
authored
127 nnoremap <silent> <Leader>S :let _pos = getpos(".")<CR>:silent keepjumps %s/\s\+$//e<CR>:call setpos(".", _pos)<CR>
8566761 @git2samus clarity
authored
128
80bb338 @git2samus initial commit
authored
129 " tab and indent width
3f82090 @git2samus changing default indentation
authored
130 set softtabstop=4
131 set shiftwidth=4
f65ae02 @git2samus fix and changing key for checktime
authored
132 " exceptions
bba3f99 @git2samus adding xml filetype to short indentation rule (2 spaces)
authored
133 au FileType ruby,html{,django},xml setlocal sw=2 sts=2
80bb338 @git2samus initial commit
authored
134
6a21ada @git2samus better textmode
authored
135 " special mode for text files
136 fun! TextMode(mode) range
137 if a:mode == 'textmode'
0991081 @git2samus don't mess with the colors
authored
138 "setlocal filetype=text
6a21ada @git2samus better textmode
authored
139 setlocal wrap
4f90068 @git2samus try to write shorter lines
authored
140 setlocal colorcolumn=
6a21ada @git2samus better textmode
authored
141 setlocal nolist
142 setlocal linebreak
143 nnoremap <buffer> j gj
144 nnoremap <buffer> k gk
145 nnoremap <buffer> 0 g0
146 nnoremap <buffer> $ g$
147 echo 'textmode'
148 else
0991081 @git2samus don't mess with the colors
authored
149 "filetype detect
6a21ada @git2samus better textmode
authored
150 setlocal nowrap
4f90068 @git2samus try to write shorter lines
authored
151 setlocal colorcolumn=80
6a21ada @git2samus better textmode
authored
152 setlocal list
153 setlocal nolinebreak
154 nunmap <buffer> j
155 nunmap <buffer> k
156 nunmap <buffer> 0
157 nunmap <buffer> $
158 echo 'notextmode'
159 endif
160 endfun
161 nnoremap <Leader>t :call TextMode('textmode')<CR>
162 nnoremap <Leader>T :call TextMode('notextmode')<CR>
80bb338 @git2samus initial commit
authored
163
8566761 @git2samus clarity
authored
164 " helpful remappings "
80bb338 @git2samus initial commit
authored
165
166 " mimic D
e081bd2 @git2samus http://learnvimscriptthehardway.stevelosh.com/chapters/05.html
authored
167 nnoremap Y y$
80bb338 @git2samus initial commit
authored
168
169 " shortcuts to change buffers the same way as tabs
e081bd2 @git2samus http://learnvimscriptthehardway.stevelosh.com/chapters/05.html
authored
170 nnoremap gb :bn<CR>
171 nnoremap gB :bp<CR>
80bb338 @git2samus initial commit
authored
172 " and to previous buffer
e081bd2 @git2samus http://learnvimscriptthehardway.stevelosh.com/chapters/05.html
authored
173 nnoremap g. :b#<CR>
80bb338 @git2samus initial commit
authored
174
8566761 @git2samus clarity
authored
175 " do not move the cursor when highlighting
176 " TODO find a more elegant way to do this :P
e081bd2 @git2samus http://learnvimscriptthehardway.stevelosh.com/chapters/05.html
authored
177 nnoremap * *Nzz
178 nnoremap # #Nzz
1a0401e @git2samus vimrc cleanup
authored
179
80bb338 @git2samus initial commit
authored
180
144c9ae @git2samus time for some hardcore remappings
authored
181 " vim zen "
182
db6367d @git2samus updates
authored
183 " avoid using escape to exit insert-mode (Ctrl-j is default)
6eaab55 @git2samus use noremap
authored
184 inoremap <CR> <ESC>
db6367d @git2samus updates
authored
185 " damn you latexmode! DO NOT STEAL MY <C-j>!!
186 imap <Leader><C-J> <Plug>IMAP_JumpForward
187 nmap <Leader><C-J> <Plug>IMAP_JumpForward
188 vmap <Leader><C-J> <Plug>IMAP_JumpForward
189
2c29903 @git2samus more zen
authored
190 " use enter to add empty lines in normal mode
191 nnoremap <CR> o<ESC>
dfe7341 @git2samus adding vim mapping for <Space> and indent level for HTML files
authored
192 " space in normal-mode saves all (modified) files
6eaab55 @git2samus use noremap
authored
193 nnoremap <Space> :wa<CR>
144c9ae @git2samus time for some hardcore remappings
authored
194
a4c1f74 @git2samus this was actually useful
authored
195 " use arrows to navigate split-windows
e081bd2 @git2samus http://learnvimscriptthehardway.stevelosh.com/chapters/05.html
authored
196 nnoremap <Up> <C-w>k
197 nnoremap <Down> <C-w>j
198 nnoremap <Left> <C-w>h
199 nnoremap <Right> <C-w>l
a4c1f74 @git2samus this was actually useful
authored
200
144c9ae @git2samus time for some hardcore remappings
authored
201
dd6fe54 @git2samus adding debugger shortcuts
authored
202 " language-specific debuggers
203 autocmd FileType python nnoremap <Leader>d oimport pdb; pdb.set_trace()<Esc>
204 autocmd FileType python nnoremap <Leader>D Oimport pdb; pdb.set_trace()<Esc>
45cd2f4 @git2samus I guess these should be local
authored
205 autocmd FileType python setlocal makeprg=pyflakes\ %\ &&\ pep8\ --ignore=E501\ %
dd6fe54 @git2samus adding debugger shortcuts
authored
206
207 autocmd FileType ruby nnoremap <Leader>d orequire "ruby-debug"; debugger<Esc>
208 autocmd FileType ruby nnoremap <Leader>D Orequire "ruby-debug"; debugger<Esc>
209
ba24be1 @git2samus erb debugger shortcuts
authored
210 autocmd FileType eruby nnoremap <Leader>d o<% require "ruby-debug"; debugger %><Esc>
211 autocmd FileType eruby nnoremap <Leader>D O<% require "ruby-debug"; debugger %><Esc>
212
dd6fe54 @git2samus adding debugger shortcuts
authored
213 autocmd FileType haml nnoremap <Leader>d o- require "ruby-debug"; debugger<Esc>
214 autocmd FileType haml nnoremap <Leader>D O- require "ruby-debug"; debugger<Esc>
215
45cd2f4 @git2samus I guess these should be local
authored
216 autocmd FileType java setlocal makeprg=javac\ %
dd6fe54 @git2samus adding debugger shortcuts
authored
217
7281873 @git2samus json indentation - idea from http://redd.it/rxmzf
authored
218 " handy command to properly indent json files
219 fun! JsonTool() range
220 execute a:firstline . "," . a:lastline . "!python -m json.tool"
221 endfun
222 comm! -range JsonTool <line1>,<line2>call JsonTool()
223
8566761 @git2samus clarity
authored
224 " extras "
80bb338 @git2samus initial commit
authored
225
226 " taken from /etc/vimrc
227 " Only do this part when compiled with support for autocommands
228 if has("autocmd")
229 " When editing a file, always jump to the last cursor position
230 autocmd BufReadPost *
231 \ if line("'\"") > 0 && line ("'\"") <= line("$") |
232 \ exe "normal! g'\"" |
233 \ endif
234 endif
235
236 " taken from /etc/vimrc (arch)
237 " Convenient command to see the difference between the current buffer and the
238 " file it was loaded from, thus the changes you made.
239 " Only define it when not defined already.
240 if !exists(":DiffOrig")
241 command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
242 \ | wincmd p | diffthis
243 endif
Something went wrong with that request. Please try again.