This repository has been archived by the owner on Jan 10, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvimrc
executable file
·172 lines (144 loc) · 4.92 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
" display options {
syntax on "syntax coloring is a first-cut debugging tool
colorscheme cyberpunk "change to taste. try `desert' or `evening'
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
set incsearch "search as you type
set hlsearch "highlight the search
set ignorecase "ignore case
set smartcase " ...unless the search uses uppercase letters
set number
" }
" 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>
" }
" 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
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
" }
" My own extra stuff:
if filereadable($HOME . "/.vimrc.extra")
source $HOME/.vimrc.extra
endif
set runtimepath^=~/.vim/bundle/ctrlp.vim
filetype plugin indent on
syntax on