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
|
" VIM configuration
syn on
set nu
set background=dark
set nobackup
set nowritebackup
set noswapfile
set noautoindent
set nosmartindent
set tabstop=2
set shiftwidth=2
set expandtab
set mouse=a
set autoread
set nocompatible
set laststatus=2
set shortmess+=I
set ignorecase
set smartcase
set title
set titleold="terminal"
set titlestring=vim:\ %F
" Command mode completion
" See https://stackoverflow.com/questions/526858/how-do-i-make-vim-do-normal-bash-like-tab-completion-for-file-names
"set wildmode=longest,list
set wildmode=longest,list,full
set wildmenu
" Thanks to http://stackoverflow.com/questions/1673649/vimrc-action-onclose
function! ResetTitle(title)
" disable vim's ability to set the title
exec "set title t_ts='' t_fs=''"
" and restore it
"exec ":!echo -e '\033kbash\033\\'\<CR>"
exec ":!xtitle " a:title
endfunction
au VimLeave *mutt/* silent call ResetTitle("mutt")
au VimLeave *remind/* silent call ResetTitle("wyrd")
" Folding
set foldmethod=syntax
set foldlevelstart=99
let g:sh_fold_enabled=1
let javaScript_fold=1
let perl_fold=1
let php_folding=1
let r_syntax_folding=1
let ruby_fold=1
let sh_fold_enabled=1
let vimsyn_folding='af'
let xml_syntax_folding=1
" PHP
let php_sql_query=1
" Filetypes
au BufNewFile,BufRead *.vue set ft=html
au BufNewFile,BufRead *.thtml set ft=php
au BufNewFile,BufRead *.mdwn set ft=ikiwiki
au BufNewFile,BufRead *.md set ft=ikiwiki
au BufNewFile,BufRead *.rem set ft=remind
au BufNewFile,BufRead *.trac set ft=tracwiki
au BufNewFile,BufRead *.tracwiki set ft=tracwiki
au BufNewFile,BufRead Vagrantfile set ft=ruby
augroup mkd
autocmd BufRead *.mkd set ai formatoptions=tcroqn2 comments=n:>
augroup END
if has("autocmd")
" Drupal *.module and *.install files.
augroup module
autocmd BufRead,BufNewFile *.profile set filetype=php
autocmd BufRead,BufNewFile *.module set filetype=php
autocmd BufRead,BufNewFile *.install set filetype=php
autocmd BufRead,BufNewFile *.test set filetype=php
augroup END
endif
" Pathogen - https://github.com/tpope/vim-pathogen
call pathogen#infect()
syntax on
filetype plugin indent on
" No modelines
" https://lwn.net/Articles/20249/
" http://usevim.com/2012/03/28/modelines/
" http://www.techrepublic.com/blog/it-security/turn-off-modeline-support-in-vim/
set nomodeline
set modelines=0
" Syntax check
let g:syntastic_mode_map={ 'mode': 'passive',
\ 'active_filetypes': [],
\ 'passive_filetypes': [] }
" Shortcut to open a new tab
nmap <ESC>n :tabnew<CR>
" Write, quit and close shortcuts using Alt-key combos
map q :wqa <CR>
map f :wq <CR>
map c :tabclose <CR>
map m :q! <CR>
map w :w <CR>
" Write, quit and close shortcuts
"map q :wqa <CR>
"map f :wq <CR>
"map t :tabclose <CR>
"map m :q! <CR>
"map w :w <CR>
" NERDTree section
" Thanks to http://stackoverflow.com/questions/1447334/how-do-you-add-nerdtree-to-your-vimrc
" Open NERDTree when vim starts
"autocmd VimEnter * NERDTree
"autocmd VimEnter * wincmd p
autocmd FileType nerdtree set relativenumber
autocmd FileType taglist set relativenumber
function TabNew(address)
execute ":tabnew"
execute ":NERDTree " a:address
endfunction
function TabNewBookmark(bookmark)
execute ":tabnew"
execute ":NERDTreeFromBookmark " a:bookmark
endfunction
function OpenNERDTree()
execute ":NERDTree"
endfunction
" Shortcuts
cnoreabbrev t NERDTree
cnoreabbrev b NERDTreeFromBookmark
cnoreabbrev s OpenSession
cnoreabbrev sload OpenSession
cnoreabbrev ssave SaveSession
command -nargs=1 -complete=dir T :call TabNew(<f-args>)
command -nargs=1 -complete=customlist,nerdtree#completeBookmarks B :call TabNewBookmark(<f-args>)
command -nargs=0 OpenNERDTree :call OpenNERDTree()
nmap <ESC>t :OpenNERDTree<CR>
" See http://superuser.com/questions/10588/how-to-make-cut-copy-paste-in-gvim-on-ubuntu-work-with-ctrlx-ctrlc-ctrlv
"imap <C-v> <C-r><C-o>+
"vmap <C-v> c<ESC>"+p
vmap <C-c> "+yi
vmap <C-x> "+c
" Workaround for mail editing. There must be a plugin enabling autoindent in
" mail composition, which is annoying.
au FileType mail set noautoindent
" For email: unfold and delete to your signature
" See https://hroy.eu/tips/vim/email-delete-til-signature/
noremap ,dd zi:.;/^-- $/d<CR>O-- <UP><End><CR><CR><UP><CR><C-O>zi
" Color scheme
"colorscheme github
"colorscheme solarized
"colorscheme gentooish
"colorscheme revolutions
"colorscheme two2tango
"colorscheme vj
"colorscheme wood
"colorscheme zenburn
"colorscheme inkpot
colorscheme xoria256
" Airline
let g:airline_powerline_fonts=1
let g:airline#extensions#tabline#enabled=1
" Powerline
"python from powerline.vim import setup as powerline_setup
"python powerline_setup()
"python del powerline_setup
set laststatus=2 " Always display the statusline in all windows
set showtabline=2 " Always display the tabline, even if there is only one tab
set noshowmode " Hide the default mode text (e.g. -- INSERT -- below the statusline)
" Tab navigation
" See http://vim.wikia.com/wiki/Alternative_tab_navigation
" http://comments.gmane.org/gmane.os.cygwin.xfree/16419
nmap <ESC>[5^ <C-PageUp>
nmap <ESC>[6^ <C-PageDown>
nnoremap <C-PageDown> :tabn<CR>
nnoremap <C-PageUp> :tabp<CR>
nmap 1 1gt
nmap 2 2gt
nmap 3 3gt
nmap 4 4gt
nmap 5 5gt
nmap 6 6gt
nmap 7 7gt
nmap 8 8gt
nmap 9 9gt
nmap 0 10gt
" Buffer navigation: Alt-{Up,Down}
map Od :bprevious<CR>
map Oc :bnext<CR>
" Window navigation
map <Left> <C-w><Left>
map <Right> <C-w><Right>
map <Down> <C-w><Down>
map <Up> <C-w><Up>
" See
" http://vim.wikia.com/wiki/Have_Vim_check_automatically_if_the_file_has_changed_externally
" http://stackoverflow.com/questions/2490227/how-does-vims-autoread-work
" http://stackoverflow.com/questions/2490227/how-does-vims-autoread-work
"au FocusGained,BufEnter * :silent! !
"au FocusLost,WinLeave * :silent! w
" Session management, see:
" http://usevim.com/2013/07/05/sessions/
" https://github.com/xolox/vim-session
" https://github.com/tpope/vim-obsession
" http://stackoverflow.com/questions/1642611/how-to-save-a-session-in-vim
" https://bocoup.com/weblog/sessions-the-vim-feature-you-probably-arent-using/
" http://vimdoc.sourceforge.net/htmldoc/usr_21.html#21.4
"let g:session_autosave_periodic=1
let g:session_autosave_silent=1
let g:session_autosave='yes'
let g:session_autoload='no'
let g:session_directory='~/.local/share/vim/sessions'
let NERDTreeMinimalUI=1
" Autosave
" See https://github.com/vim-scripts/vim-auto-save
"let g:auto_save = 1
|