-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
205 lines (176 loc) · 6.35 KB
/
.vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
" display options {
set nu
syntax on "syntax coloring is a first-cut debugging tool
colorscheme desert "change to taste. try `desert' or `evening' or tomorrownight
set wrap "wrap long lines
set scrolloff=3 "keep three lines visible above and below
set ruler showcmd "give line, column, and command in the status line
set laststatus=2 "always show the status line
"make filename-completion more terminal-like
set wildmode=longest:full
set wildmenu "a menu for resolving ambiguous tab-completion
"files we never want to edit
set wildignore=*.pyc,*.sw[pno],.*.bak,.*.tmp
" }
" searching {
set incsearch "search as you type
set hlsearch "highlight the search
set ignorecase "ignore case
set smartcase " ...unless the search uses uppercase letters
"Use case-sensitive search for the * command though.
:nnoremap * /\<<C-R>=expand('<cword>')<CR>\>\C<CR>
:nnoremap # /\<<C-R>=expand('<cword>')<CR>\>\C<CR>
" }
" statusline {
" compare the default statusline: %<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P
set statusline = " clear!
set statusline +=%< " truncation point
set statusline +=%2n: " buffer number
set statusline +=%f\ " relative path to file
set statusline +=%#Error#%m " modified flag [+], highlighted as error
set statusline +=%r " readonly flag [RO]
set statusline +=%##%y " filetype [ruby], reset color
set statusline +=%= " split point for left and right justification
set statusline +=row:\ %3l " current line number
set statusline +=/%-3L\ " number of lines in buffer
set statusline +=(%3P)\ " percentage through buffer
set statusline +=col:\ %3v\ " current virtual column number (visual count)
" }
" movement options {
"enable mouse in normal, visual, help, prompt modes
"I skip insert/command modes because it prevents proper middle-click pasting
"TODO: can we get paste to work even with mouse enabled?
set mouse=nvrh
" Moving up/down moves visually.
" This makes files with very long lines much more manageable.
nnoremap j gj
nnoremap k gk
" Moving left/right will wrap around to the previous/next line.
set whichwrap=b,s,h,l,<,>,~,[,]
" Backspace will delete whatever is behind your cursor.
set backspace=indent,eol,start
"Bind the 'old' up and down. Use these to skip past a very long line.
noremap gj j
noremap gk k
" }
" general usability {
"turn off the annoying "ding!"
set visualbell
"allow setting extra option directly in files
"example: "vim: syntax=vim"
set modeline
"don't clobber the buffer when pasting in visual mode
vmap P p
vnoremap p "_dP
" }
" windows-style mappings {
"ctrl+S to save.
"NOTE: put this in ~/.bashrc for it to work properly in terminal vim:
" stty -ixon -ixoff
map <c-s> :update<cr>
imap <c-s> <c-o><c-s>
"ctrl+A to select all
noremap <c-a> ggVG
imap <c-a> <esc><c-a>
"ctrl+C to copy
map <c-c> "+y
"ctrl+Y to redo
map <c-y> <c-r>
imap <c-y> <c-o><c-r>
imap <c-r> <c-o><c-r>
"ctrl+Z to undo
"map <c-z> u "this clobbers UNIX ctrl+z to background vim
imap <c-z> <c-o>u
"ctrl+Q to save/quit
map <c-q> :update\|q<cr>
imap <c-q> <c-o><c-q>
"ctrl+V to paste
map <c-v> "+gP
imap <c-v> <c-o>"+gP
vmap <c-v> "+P
"replace <CTRL-V> with <CTRL-B>
noremap <c-b> <c-v>
inoremap <c-b> <c-v>
" }
" common typos {
" Often I hold shift too long when issuing these commands.
command! Q q
command! Qall qall
command! W w
command! Wall wall
command! WQ wq
command! Wq wq
command! -bang Redraw redraw!
nmap Q: :q
" this one causes a pause whenever you use q, so I don't use it
" nmap q: :q
"never use Ex mode -- I never *mean* to press it
nnoremap Q <ESC>
"never use F1 -- I'm reaching for escape
noremap <F1> <ESC>
noremap! <F1> <ESC>
lnoremap <F1> <ESC>
" }
" multiple files {
" be smarter about multiple buffers / vim instances
"quick buffer switching with TAB, even with edited files
set hidden
nmap <TAB> :bn<CR>
nmap <S-TAB> :bp<CR>
set autoread "auto-reload files, if there's no conflict
set shortmess+=IA "no intro message, no swap-file message
"replacement for CTRL-I, also known as <tab>
noremap <C-P> <C-I>
"window switching: ctrl+[hjkl]
nnoremap <C-J> <C-W>j
nnoremap <C-K> <C-W>k
nnoremap <C-H> <C-W>h
nnoremap <C-L> <C-W>l
nnoremap <C-Q> <C-W>q
"tab switching: ctrl+left/right
nnoremap Od :tabp<CR>
nnoremap Oc :tabN<CR>
" }
"indentation options {
set expandtab "use spaces, not tabs
set softtabstop=4 shiftwidth=4 "4-space indents
set shiftround "always use a multiple of 4 for indents
set smarttab "backspace to remove space-indents
set autoindent "auto-indent for code blocks
"DONT USE: smartindent "it does stupid things with comments
"smart indenting by filetype, better than smartindent
filetype on
filetype indent on
filetype plugin on
" }
"extra filetypes {
au BufNewFile,BufRead *.js.tmpl set filetype=javascript
au BufNewFile,BufRead *.css.tmpl set filetype=css
au BufNewFile,BufRead *.pxi set filetype=pyrex
au BufNewFile,BufRead *.md set filetype=markdown
" }
" tkdiff-like bindings for vimdiff {
if &diff
"next match
nnoremap m ]cz.
"previous match
nnoremap M [cz.
"refresh the diff
nnoremap R :w\|set nodiff\|set diff<cr>
"quit, both panes
nnoremap q :qall<cr>
"show me the top of the "new" file
autocmd VimEnter * normal lgg
endif
" }
" Pathogen: {
" keep plugins nicely bundled in separate folders.
" http://www.vim.org/scripts/script.php?script_id=2332
runtime autoload/pathogen.vim
if exists('g:loaded_pathogen')
call pathogen#infect() "load the bundles, if possible
Helptags "plus any bundled help
runtime bundle_config.vim "give me a chance to configure the plugins
endif
" }
" vim:et:sts=4:sw=4