-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
321 lines (242 loc) · 8.06 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
" .vimrc File
"Forget compatibility with Vi. Who cares.
set nocompatible
call pathogen#incubate()
call pathogen#helptags()
"Status line with airline
" let g:airline#extensions#tabline#enabled = 1
let g:gitgutter_realtime = 0
let g:gitgutter_eager = 0
"Enable filetypes
filetype on
filetype plugin on
filetype indent on
syntax on
set ruler
"Tab stuff
set tabstop=2
set shiftwidth=2
set softtabstop=2
set expandtab
if has("gui_running")
" See ~/.gvimrc
" http://blog.toddwerth.com/entries/show/8
colorscheme desertExMine
colorscheme vilight
colorscheme solarized
colorscheme Tomorrow-Night
colorscheme Tomorrow-Night-Bright
colorscheme molokai " use this color scheme
set guifont=Inconsolata\ 13 " use this font
" set lines=50 " height = 50 lines
" set columns=100 " width = 100 columns
set background=dark " adapt colors for background
" set selectmode=mouse,key,cmd
" set keymodel=
else
" colorscheme molokai " use this color scheme
set background=dark " adapt colors for background
colorscheme molokai
endif
"Show command in bottom right portion of the screen
set showcmd
"Show lines numbers
set number
"Prefer relative line numbering?
"set relativenumber"
"Indent stuff
set smartindent
set autoindent
"Always show the status line
set laststatus=2
"Prefer a slightly higher line height
set linespace=1
"Set incremental searching"
set incsearch
"Highlight searching
set hlsearch
"Disable last search term
nmap <silent> <C-N> :noh<CR>
" case insensitive search
set ignorecase
set smartcase
"Hide MacVim toolbar by default
set go-=T
set wrap
" set linebreak
set nolist " list disables linebreak
set textwidth=0
set wrapmargin=0
"Hard-wrap paragraphs of text
nnoremap <leader>q gqip
"folding settings
set foldmethod=indent "fold based on indent
set foldnestmax=100 "deepest fold is 10 levels
set nofoldenable "dont fold by default
" Note, perl automatically sets foldmethod in the syntax file
"autocmd Syntax c,cpp,vim,xml,html,xhtml,php setlocal foldmethod=syntax
"autocmd Syntax c,cpp,vim,xml,html,xhtml,perl,php normal zR
"Split windows below the current window.
set splitbelow
"Shortcut to fold tags with leader (usually \) + ft
" nnoremap <leader>ft Vatzf
nmap <space> :
"Want a different map leader than \
let mapleader = ","
"Set up an HTML5 template for all new .html files
"autocmd BufNewFile * silent! 0r $VIMHOME/templates/%:e.tpl
" Save files when focus is lost, except RO and untitled buffers
:au FocusLost silent! :wa
"Load the current buffer in Firefox - Mac specific.
abbrev ff :! firefox %:p<cr>
"Map last command line command to ,.
nmap <leader>. @:
"Map a change directory to the desktop - Mac specific
nmap <leader>d :cd ~/Desktop<cr>:e.<cr>
"Map go to the directory of the current file
nmap <leader>cdh :lcd %:p:h<cr>
"Shortcut for editing vimrc file in a new tab
nmap <leader>ev :tabedit $MYVIMRC<cr>
"Change zen coding plugin expansion key to shift + e
let g:user_zen_expandabbr_key = '<C-e>'
"Faster shortcut for commenting. Requires T-Comment plugin
map <leader>c <c-_><c-_>
map <leader>C <c-_>b
"Automatically change current directory to that of the file in the buffer
"autocmd BufEnter * cd %:p:h
nmap <leader>gh :lcd %:p:h<cr>
"Map code completion to , + tab
imap <leader><tab> <C-x><C-o>
" More useful command-line completion
set wildmenu
"Auto-completion menu
set wildmode=list:longest
"http://vim.wikia.com/wiki/Make_Vim_completion_popup_menu_work_just_like_in_an_IDE
" set completeopt=longest,menuone
" inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
" inoremap <expr> <C-n> pumvisible() ? '<C-n>' :
" \ '<C-n><C-r>=pumvisible() ? "\<lt>Down>" : ""<CR>'
" inoremap <expr> <M-,> pumvisible() ? '<C-n>' :
" \ '<C-x><C-o><C-n><C-p><C-r>=pumvisible() ? "\<lt>Down>" : ""<CR>'
"Map escape key to jj -- much faster
imap jj <esc>
"Delete all buffers (via Derek Wyatt)
nmap <silent> ,da :exec "1," . bufnr('$') . "bd"<cr>
"Bubble single lines (kicks butt)
"http://vimcasts.org/episodes/bubbling-text/
nmap <C-Up> ddkP
nmap <C-Down> ddp
"Bubble multiple lines
vmap <C-Up> xkP`[V`]
vmap <C-Down> xp`[V`]
" Source the vimrc file after saving it. This way, you don't have to reload Vim to see the changes.
if has("autocmd")
augroup myvimrchooks
au!
autocmd bufwritepost .vimrc source ~/.vimrc
augroup END
endif
" easier window navigation
nmap <C-h> <C-w>h
nmap <C-j> <C-w>j
nmap <C-k> <C-w>k
nmap <C-l> <C-w>l
"Align with tabular.vim
if exists(":Tabularize")
nmap <Leader>a= :Tabularize /=<CR>
vmap <Leader>a= :Tabularize /=<CR>
nmap <Leader>a: :Tabularize /:\zs<CR>
vmap <Leader>a: :Tabularize /:\zs<CR>
endif
"Remove trailing space
autocmd FileType js,php autocmd BufWritePre <buffer> :%s/\s\+$//e
"------------------------"
"NERDTREE PLUGIN SETTINGS
"------------------------"
"Shortcut for NERDTreeToggle
nmap <leader>nt :NERDTreeToggle <CR>
"Show hidden files in NerdTree
let NERDTreeShowHidden=1
"autopen NERDTree and focus cursor in new document
"autocmd VimEnter * NERDTree
"autocmd VimEnter * wincmd p
"Helpeful abbreviations
iab lorem Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
iab llorem Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
"Spelling corrects. Just for example. Add yours below.
iab teh the
iab Teh The
" Train yourself to use hjkl
" Disable arrow keys *shock* *horror*!
"inoremap <Up> <NOP>
"inoremap <Down> <NOP>
"inoremap <Left> <NOP>
"inoremap <Right> <NOP>
"noremap <Up> <NOP>
"noremap <Down> <NOP>
"noremap <Left> <NOP>
"noremap <Right> <NOP>
" Get to home dir easier
" <leader>hm is easier to type than :cd ~
nmap <leader>hm :cd ~/ <CR>
" Alphabetically sort CSS properties in file with :SortCSS
:command! SortCSS :g#\({\n\)\@<=#.,/}/sort
" Shortcut to opening a virtual split to right of current pane
" Makes more sense than opening to the left
nmap <leader>bv :bel vsp
" Backups
set backupdir=~/.vim/tmp/backup/ " backups
set directory=~/.vim/tmp/swap/ " swap files
set backup " enable backup
"Copy/Paste ctr-c ctr-v, pretty cool.
vmap <C-c> "+yi
vmap <C-x> "+c
vmap <C-v> c<ESC>"+p
imap <C-v> <ESC>"+pa
let g:snipMate = {}
let g:snipMate.scope_aliases = {}
"Activa snippets de PHP en archivos HTML y viceversa
" au BufRead *.html set ft=html.php
" au BufNewFile *.html set ft=html.php
"
" au BufRead *.php set ft=php.html
" au BufNewFile *.php set ft=php.html
"nmap <S-F5> :w <cr> :!extranetupload.sh %:p <cr>
"nmap <S-F5> :w <cr> :!intranetupload.sh %:p <cr>
au FileType php set omnifunc=phpcomplete#CompletePHP
"Close buffer window
autocmd CursorMovedI * if pumvisible() == 0|pclose|endif
autocmd InsertLeave * if pumvisible() == 0|pclose|endif
:set completeopt=longest,menuone
:inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
inoremap <expr> <C-n> pumvisible() ? '<C-n>' :
\ '<C-n><C-r>=pumvisible() ? "\<lt>Down>" : ""<CR>'
inoremap <expr> <M-,> pumvisible() ? '<C-n>' :
\ '<C-x><C-o><C-n><C-p><C-r>=pumvisible() ? "\<lt>Down>" : ""<CR>'
"Auto refresh tags
" basic syntax checker for php
nmap <leader>s :!php -l %<CR>
let g:omni_sql_no_default_maps = 1
" PHP Generated Code Highlights (HTML & SQL)
let php_sql_query=1
let php_htmlInStrings=1
" Javascript indenter
let g:SimpleJsIndenter_BriefMode = 1
" Auto compile less files (compressed)
au BufNewFile,BufRead *.less set filetype=less
if executable('lessc')
autocmd FileWritePost,BufWritePost *.less :silent !lessc %:p %:p:r.css :grep
endif
inoremap <leader>d <ESC>:call PhpDocSingle()<CR>i
nnoremap <leader>d :call PhpDocSingle()<CR>
vnoremap <leader>d :call PhpDocRange()<CR>
" Ctrl-P options
let g:ctrlp_map = '<c-p>'
let g:ctrlp_working_path_mode = 2
let g:ctrlp_custom_ignore = {
\ 'dir': '\.git$\|\.hg$\|\.svn$',
\ 'file': '\.exe$\|\.so$\|\.dll$'
\ }
let g:ctrlp_extensions = ['buffertag', 'tag', 'line', 'dir']
" Gist options
let g:gist_clip_command = 'xclip -selection clipboard'