-
Notifications
You must be signed in to change notification settings - Fork 4
/
.vimrc
323 lines (241 loc) · 6.49 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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
" .vimrc
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Runtime Path Manipulation
filetype off
execute pathogen#infect()
" No need to be compatible with vi
set nocompatible
" Show the mode (Command mode=null, INSERT, APPEND, ...)
set showmode
" Show command in action
set showcmd
" File type aware
filetype plugin indent on
" Syntax highlighting
syntax enable
" But only up to certain column to speed up
set synmaxcol=120
" Show matching parenthesis etc.
set showmatch
" Load matchit.vim, but only if the user hasn't installed a newer version.
if !exists('g:loaded_matchit') && findfile('plugin/matchit.vim', &rtp) ==# ''
runtime! macros/matchit.vim
endif
" Background
set background=light
colorscheme solarized
set cursorline
set cursorcolumn
" Allow color schemes to do bright colors without forcing bold.
"if &t_Co == 8 && $TERM !~# '^linux'
" set t_Co=16
"endif
" Show weird characters
set list
if &listchars ==# 'eol:$'
set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+
if !has('win32') && (&termencoding ==# 'utf-8' || &encoding ==# 'utf-8')
let &listchars = "tab:\u21e5 ,trail:\u2423,extends:\u21c9,precedes:\u21c7,nbsp:\u00b7"
endif
endif
" Line numbers
set number
" Cursor position
set ruler
" Always show statusline
set laststatus=2
" Show title
"set title
" TODO: What is this?
"set display+=lastline
" Use left-right keys in the menu
set wildmenu
" Use TAB to expand the menu?
set wildmode=longest,list:longest
" Do not beep
set noerrorbells visualbell t_vb=
if has('autocmd')
autocmd GUIEnter * set visualbell t_vb=
endif
" Fast terminal - nicer redraw
set ttyfast
" Do not wrap long lines
set nowrap
" Width of text - then wrap
set textwidth=120
" Show a column
if has('colorcolumn')
set colorcolumn=80
end
" Make cursor stay in the center of the screen
set scrolloff=10
set sidescrolloff=5
if has('gui_running')
set guifont=Inconsolata:h18
endif
" VimRoom width
if !exists( "g:vimroom_width" )
let g:vimroom_width=120
endif
" Allow backspacing over identation, end-of-line, and start-of-line
set backspace=2
" Allow for buffers with not yet saved changes
set hidden
" Reread files changed on disk but not in vim
set autoread
" Recognize also Mac EOL
set fileformats+=mac
" History
if &history < 1000
set history=1000
endif
" Number of page tabs at max
if &tabpagemax < 50
set tabpagemax=50
endif
" Save vim information for later usage
if !empty(&viminfo)
set viminfo^=!
endif
" Incremental search
set incsearch
" Highlight search
set hlsearch
" Search lower and upper case with /string, but case sensitive with /String
" search with * works as usual
set ignorecase
set smartcase
" Spell
set spell
" Autoindentation
set autoindent
" Use 2 char width for displaying a TAB
set tabstop=2
" Use 2 spaces when using autoindent/cindent used with > and <
set shiftwidth=2
" TAB in the start of a line inserts 'shiftwidth' spaces instead of 'tabstop'
set smarttab
" Expand tabs to spaces when TAB is pressed.
set expandtab
" Make backspace and delete recognize to remove 'shiftwidth' number of spaces
set softtabstop=2
" Indenting follows 'shifwidth', i.e., jump to next indenting line and not
" 'shiftwidth' from the current position
set shiftround
" Do not scan all include files for autocompletion
set complete-=i
set complete=.,b,u
" Folding
set foldmethod=indent
set foldignore=
" Define shell type for :! or :sh
set shell=/bin/bash
" Autosave file when switiching to terminal with :!
set autowrite
" Wait for ???
set ttimeout
set ttimeoutlen=50
" Keybindings et al.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" nnoremap = normal mode
" vnoremap = visual mode
" inoremap = insert mode
" Bring own help
" nnoremap <leader>h :e ~/.vim/myhelp.txt<CR>
nnoremap <leader>h :tabnew ~/.vim/myhelp.txt<CR>
" Make use of a mouse
set mouse=a
" Make backspace work nicely
set backspace=indent,eol,start
" ; is an alias for :
nnoremap ; :
" Avoid system help
inoremap <F1> <ESC>
nnoremap <F1> <ESC>
vnoremap <F1> <ESC>
" Avoid silly error
nnoremap :Wq :wq
nnoremap :W :w
" Search with ask
nnoremap <leader>a :Ack
" Toogle smart pasting
"set pastetoggle=<leader>p
nnoremap <leader>p :set invpaste paste?<CR>
" Reselect pasted text
nnoremap <leader>v V`]
" Use TAB to jump between brackets
" nnoremap <tab> %
" vnoremap <tab> %
" Completition menu
imap <tab> <C-p>
" Remove trailing whitespace on <leader><space>
nnoremap <leader><space> :%s/\s\+$//<cr>:let @/=''<CR>
" Toggle list
nnoremap <leader>l :set invlist<CR>
" Rewrap a paragraph
nnoremap <leader>q gq
nnoremap <leader>q gqip
nnoremap <leader>q gqap
" Splitting windows
nnoremap <leader>sv <C-w>v<C-w>l
nnoremap <leader>sh :sp<CR>
nnoremap <leader>so <vC-w>s<C-w>l
nnoremap <leader>sq <C-W>o
" Moving between windows
nnoremap <leader><left> <C-w>h
nnoremap <leader><up> <C-w>k
nnoremap <leader><down> <C-w>j
nnoremap <leader><right> <C-w>l
" Moving between buffers
nnoremap <leader>bc :badd<space>
nnoremap <leader>bs :Scratch<CR>
nnoremap <leader>bn :bnext<CR>
nnoremap <leader>bp :bprevious<CR>
nnoremap <leader>bk :bdelete<CR>
" Moving between tabs
nnoremap <leader>tc :tabnew<space>
nnoremap <leader>ts :tabnew<CR>
nnoremap <leader>tn :tabn<CR>
nnoremap <leader>tp :tabp<CR>
nnoremap <leader>tk :tabclose<CR>
" Toggle numbers
nnoremap <leader>n :NumbersToggle<CR>
nnoremap <leader>nn :NumbersOnOff<CR>
" Toggle VimRoom
" nnoremap <silent> <leader>w <Plug>VimroomToggle<CR>
nnoremap <leader>w :VimroomToggle<CR>
" Toggle highlight search results
nnoremap <leader>hh :nohlsearch<CR>
" Commenting
xmap <leader>cc <Plug>Commentary
nmap <leader>cc <Plug>Commentary
nmap <leader>cc <Plug>CommentaryLine
nmap <leader>cu <Plug>CommentaryUndo
" Correcting spelling mistakes
nnoremap \s ea<C-X><C-S>
"compiling using F3
"map <F3> : call CompileGcc()<CR>
"func! CompileGcc()
" exec "w"
" exec "!gcc % -o %<"
"endfunc
"compile and execute using F9
"map <F9> :call CompileRunGcc()<CR>
"func! CompileRunGcc()
" exec "w"
" exec "!gcc % -o %<"
" exec "! ./%<"
"endfunc
"
" Execute Pyhon file being edited with <Shift> + e:
" map <buffer> <S-e> :w<CR>:!/usr/bin/env python % <CR>
" File specific stuff
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Comment character using commentary.vim
"autocmd FileType apache set commentstring=#\ %s
" My functions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" function! MyHelp()
" endfunction
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" .vimrc ends here