-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
194 lines (166 loc) · 7.7 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
"-------------------------------------------------------
" My ViM Run Commands (vimrc)
" Chandan Singh
"-------------------------------------------------------
set nocompatible " don't use vi compatibility; I want all the new features in Vim
set nu " enable numbering
set autoindent " when opening a new line and no filetype-specific indenting is enabled, keep the same indent as the line you're currently on.
set cindent " automatic indentation for C code
set smartindent " some more indenting smartness
set incsearch " search next match as you type; incremental (emacs-style) search
set laststatus=2 " status line always displayed
set ignorecase " case insensitive searching
set smartcase " with 'ignorecase'on, if pattern contains an uppercase letter, search case sensitive, otherwise not.
set scrolloff=2 " have at least two lines of context visible around the cursor
set confirm " instead of failing commands because of changes in file, ask whether to save
set wildmode=longest,list " changed filename completion behaviour (complete till lc-substring, then list)
set showcmd " Show current vim command in status bar
set nowrap
"-------------------------------------------------------
" expand tabs to spaces
set expandtab
"-------------------------------------------------------
"-------------------------------------------------------
" Tabstop and indent shiftwidth config.
" set default values
set tabstop=2
set shiftwidth=2
" tab space value and indent shiftwidth for some filetypes
autocmd FileType python set tabstop=4 | set shiftwidth=4
autocmd FileType php set tabstop=2 | set shiftwidth=2
autocmd FileType css set tabstop=2 | set shiftwidth=2
autocmd FileType ruby set tabstop=2 | set shiftwidth=2
autocmd FileType js set tabstop=2 | set shiftwidth=2
autocmd FileType java set tabstop=2 | set shiftwidth=2
autocmd FileType html set tabstop=2 | set shiftwidth=2
autocmd FileType xhtml set tabstop=2 | set shiftwidth=2
autocmd FileType c set tabstop=4 | set shiftwidth=4
autocmd FileType cpp set tabstop=4 | set shiftwidth=4
"-------------------------------------------------------
"-------------------------------------------------------
" Some things to do, only if vim version is 600 or greater
if version >= 600
syntax enable " enable syntax highlighting, but keep current colour settings
filetype on
filetype plugin indent on
else
syntax on " enable syntax highlighting, overriding current colour settings with defaults
endif
"-------------------------------------------------------
"-------------------------------------------------------
" allows typing :tabv myfile.txt to open the specified
" file in a new read-only tab
cabbrev tabv tab sview +setlocal\ nomodifiable
"-------------------------------------------------------
"-------------------------------------------------------
" press F5 to insert the current timestamp
:nnoremap <F5> "=strftime("%c")<CR>P
:inoremap <F5> <C-R>=strftime("%c")<CR>
"-------------------------------------------------------
"-------------------------------------------------------
" press Ctrl-Left or Ctrl-Right to go to the previous or next tabs
" press Alt-Left or Alt-Right to move the current tab to the left or right
nnoremap <C-Left> :tabprevious<CR>
nnoremap <C-Right> :tabnext<CR>
nnoremap <silent> <A-Left> :execute 'silent! tabmove ' . (tabpagenr()-2)<CR>
nnoremap <silent> <A-Right> :execute 'silent! tabmove ' . tabpagenr()<CR>
"-------------------------------------------------------
" Recognize .rkt files as scheme source
if version >= 600
au BufNewFile,BufRead *.rkt set filetype=scheme
endif
"-------------------------------------------------------
" Yash's pro-coder additions
set makeprg=g++\ %\ -Wall
map <F3> :w <CR> :make<CR> <CR>
map <F2> :cn<CR>
"-------------------------------------------------------
"-------------------------------------------------------
" Open template cpp file while opening new file
autocmd BufNewFile *.cpp 0r ~/programming/templates/base.cpp
"-------------------------------------------------------
"-------------------------------------------------------
if has("autocmd")
augroup module
" Drupal *.module and *.install files.
autocmd BufRead,BufNewFile *.module set filetype=php
autocmd BufRead,BufNewFile *.install set filetype=php
autocmd BufRead,BufNewFile *.test set filetype=php
autocmd BufRead,BufNewFile *.inc set filetype=php
autocmd BufRead,BufNewFile *.profile set filetype=php
autocmd BufRead,BufNewFile *.view set filetype=php
autocmd BufRead,BufNewFile *.theme set filetype=php
" Treat *.md files as markdown.
autocmd BufRead,BufNewFile *.md set filetype=markdown
augroup END
endif
syntax on
"-------------------------------------------------------
"-------------------------------------------------------
" Don't highlight all search results
set nohlsearch
"-------------------------------------------------------
"-------------------------------------------------------
" Powerline config
set rtp+=/home/enigma/.local/lib/python2.7/site-packages/powerline/bindings/vim/
set laststatus=2
set t_Co=256
set encoding=utf-8 " Necessary to show Unicode glyphs
"-------------------------------------------------------
"-------------------------------------------------------
" Syntastic config
let g:syntastic_php_checkers = ['php']
let g:syntastic_mode_map = { 'mode': 'active', 'passive_filetypes': ['java'] }
"-------------------------------------------------------
"-------------------------------------------------------
" Folds config
set foldmethod=indent
set foldnestmax=10
"-------------------------------------------------------
command NE NERDTree " Shortcut for NERDTree
colorscheme wombat256mod " Set colorscheme
let html_use_css=1
"-------------------------------------------------------
" Don't clutter dirs with tmp & swp
set backupdir=/home/enigma/.tmp
set directory=/home/enigma/.tmp
"-------------------------------------------------------
"-------------------------------------------------------
" Higihlight background beyond 80 characters
let &colorcolumn=join(range(81,999),",")
highlight ColorColumn ctermbg=235 guibg=#2c2d27
"-------------------------------------------------------
"-------------------------------------------------------
" Command tab-complete settings
set wildmenu
set wildmode=full
"-------------------------------------------------------
"-------------------------------------------------------
" Remove trailing whitespaces on pressing F5.
nnoremap <silent> <F5> :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar>:nohl<CR>
" Highlight trailing whitespaces.
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
"-------------------------------------------------------
"-------------------------------------------------------
" Smart autocomplete settings.
" Don't select first match, always show popup.
set completeopt=longest,menuone
" Select option on pressing Enter.
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
"-------------------------------------------------------
"-------------------------------------------------------
" PHP DocBlock key bindings
autocmd FileType php inoremap <C-d> <ESC>:call PhpDocSingle()<CR>i
autocmd FileType php nnoremap <C-d> :call PhpDocSingle()<CR>
autocmd FileType php vnoremap <C-d> :call PhpDocRange()<CR>
"-------------------------------------------------------
"-------------------------------------------------------
" Pathogen setup
execute pathogen#infect()
call pathogen#helptags() "generate helptags for everything in 'runtimepath'
"-------------------------------------------------------
"-------------------------------------------------------
" Map shortcut for saving file with sudo. Use `:w!!` to save in this case.
cmap w!! w !sudo tee >/dev/null %
"-------------------------------------------------------