-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
202 lines (159 loc) · 4.79 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
"
" MAIN CUSTOMIZATION FILE
"
" Enable loading filetype and indentation plugins
filetype plugin on
filetype indent on
" Turn syntax highlighting on
syntax on
"
" GLOBAL SETTINGS
"
" Enable color scheme for vim
if has("gui_running")
set guioptions-=T
set background=dark
set t_Co=256
set background=dark
colorscheme jellybeans
set nu
else
colorscheme zellner
set background=dark
set nonu
endif
" Write contents of the file, if it has been modified, on buffer exit
set autowrite
" Allow backspacing over everything
set backspace=indent,eol,start
" Insert mode completion options
" set completeopt=menu,longest,preview
" Use UTF-8 as the default buffer encoding
set enc=utf-8
" Remember up to 100 'colon' commmands and search patterns
set history=100
" Enable incremental search
set incsearch
" Always show status line, even for one window
set laststatus=2
" Jump to matching bracket for 2/10th of a second (works with showmatch)
set matchtime=2
" Don't highlight results of a search
set nohlsearch
" Enable CTRL-A/CTRL-X to work on octal and hex numbers, as well as characters
set nrformats=octal,hex,alpha
" Use F10 to toggle 'paste' mode
set pastetoggle=<F10>
" Show line, column number, and relative position within a file in the status line
set ruler
" Scroll when cursor gets within 3 characters of top/bottom edge
set scrolloff=3
" Round indent to multiple of 'shiftwidth' for > and < commands
set shiftround
" Use 4 spaces for (auto)indent
set shiftwidth=4
" Show (partial) commands (or size of selection in Visual mode) in the status line
set showcmd
" When a bracket is inserted, briefly jump to a matching one
set showmatch
" Don't request terminal version string (for xterm)
set t_RV=
" Use 4 spaces for <Tab> and :retab
set tabstop=4
" Write swap file to disk after every 50 characters
set updatecount=50
" Ignore certain types of files on completion
set wildignore+=*.o,*.obj,*.pyc,.git
" Remember things between sessions
"
" '20 - remember marks for 20 previous files
" \"50 - save 50 lines for each register
" :20 - remember 20 items in command-line history
" % - remember the buffer list (if vim started without a file arg)
" n - set name of viminfo file
set viminfo='20,\"50,:20,%,n~/.viminfo
" Use menu to show command-line completion (in 'full' case)
set wildmenu
" Set command-line completion mode:
" - on first <Tab>, when more than one match, list all matches and complete
" the longest common string
" - on second <Tab>, complete the next full match and show menu
set wildmode=list:longest,full
" Go back to the position the cursor was on the last time this file was edited
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")|execute("normal `\"")|endif
" Fix my <Backspace> key (in Mac OS X Terminal)
set t_kb=
fixdel
" Avoid loading MatchParen plugin
let loaded_matchparen = 1
" netRW: Open files in a split window
let g:netrw_browse_split = 1
"
" MAPPINGS
"
" save changes
map ,s :w<CR>
" exit vim without saving any changes
map ,q :q!<CR>
" exit vim saving changes
map ,w :x<CR>
" switch to upper/lower window quickly
map <C-J> <C-W>j
map <C-K> <C-W>k
" use CTRL-F for omni completion
imap <C-F>
" map CTRL-L to piece-wise copying of the line above the current one
imap <C-L> a<esc>kywgi<esc>Pla<bs>
" map ,f to display all lines with keyword under cursor and ask which one to
" jump to
nmap ,f [I:let nr = input("Which one: ")<Bar>exe "normal " . nr ."[\t"<CR>
" use <F6> to toggle line numbers
nmap <silent> <F6> :set number!<CR>
" page down with <Space>
nmap <Space> <PageDown>
" open filename under cursor in a new window (use current file's working
" directory)
nmap gf :new %:p:h/<cfile><CR>
" map <Alt-p> and <Alt-P> to paste below/above and reformat
nnoremap <Esc>P P'[v']=
nnoremap <Esc>p p'[v']=
" visual shifting (does not exit Visual mode)
vnoremap < <gv
vnoremap > >gv
" Switching tabs
" For mac users (using the 'apple' key)
map <D-S-]> gt
map <D-S-[> gT
map <D-1> 1gt
map <D-2> 2gt
map <D-3> 3gt
map <D-4> 4gt
map <D-5> 5gt
map <D-6> 6gt
map <D-7> 7gt
map <D-8> 8gt
map <D-9> 9gt
map <D-0> :tablast<CR>
" Generic highlight changes
highlight Comment cterm=none ctermfg=Gray
highlight IncSearch cterm=none ctermfg=Black ctermbg=DarkYellow
highlight Search cterm=none ctermfg=Black ctermbg=DarkYellow
highlight String cterm=none ctermfg=DarkGreen
highlight treeDir cterm=none ctermfg=Cyan
highlight treeUp cterm=none ctermfg=DarkYellow
highlight treeCWD cterm=none ctermfg=DarkYellow
highlight netrwDir cterm=none ctermfg=Cyan
" Set up cscope options
if has("cscope")
set csprg=cscope
set csto=0
set cst
set nocsverb
cs add cscope.out
set csverb
map <C-_> :cstag <C-R>=expand("<cword>")<CR><CR>
map g<C-]> :cs find 3 <C-R>=expand("<cword>")<CR><CR>
map g<C-\> :cs find 0 <C-R>=expand("<cword>")<CR><CR>
endif
" Set the <Leader> for combo commands
let mapleader = ","