-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc.local
executable file
·206 lines (170 loc) · 6.97 KB
/
.vimrc.local
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
" Formatting {
" tabs = 4 spaces
set autoindent " Indent at the same level of the previous line
set shiftwidth=4 " Use indents of 4 spaces
set noexpandtab " Tabs are spaces, not tabs
set tabstop=4 " An indentation every four columns
set softtabstop=4 " Let backspace delete indent
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
" color, syntax highlighting
au BufRead,BufNewFile *.ctp set filetype=php " special handling for .ctp, odd (must be above filetype plugin indent on)
au BufRead,BufNewFile *.thtml set filetype=php " special handling for .ctp, odd (must be above filetype plugin indent on)
au BufRead,BufNewFile *.dust set filetype=html " special handling for .dust
au BufRead,BufNewFile *.scss set filetype=css " special handling for .dust
au BufRead,BufNewFile *.txt set ft=sh " opens .txt w/highlight
" }
" Navigation {
" Command-line navigation
cnoremap <C-x> <Right>
cnoremap <C-z> <Left>
" Ctrl+Left/Right to switch tabs
nnoremap <C-Left> gT
nnoremap <C-Right> gt
" Control+Tab (+Shift, for reverse direction) to switch through tabs
noremap <C-Tab> gt
noremap <C-S-Tab> gT
" Control+t for new tab
nnoremap <C-t> :tabnew<CR>
" remap arrow keys in insert mode, so that they escape and move
inoremap <up> <esc>k
inoremap <down> <esc>j
" remap Shift+arrow in insert mode, escape and move, includes left/right
inoremap <S-up> <esc>k
inoremap <S-down> <esc>j
inoremap <S-right> <esc>ll
inoremap <S-left> <esc>
" }
" tagbars config {
nmap <F8> :TagbarToggle<CR> " f8 to turn on/off
let g:tagbar_autofocus = 1 " auto focus after opening tagbar
let g:tagbar_autoclose = 1 " auto close after choosing a tag
" recommended by: http://stackoverflow.com/questions/15425800/ctags-jsctags-doctorjs-tagbar-step-by-step
"set tags=./tags,tags;/,~/.ctags
" }
" Filetype specific {
" JavaScript
" autocmd BufRead,BufNewFile *.json setfiletype javascript
autocmd FileType javascript setlocal expandtab shiftwidth=2 tabstop=2 softtabstop=2 ts=2 sts=2 sw=2 noexpandtab
let javascript_enable_domhtmlcss=1
" Vimscript
autocmd FileType vim setlocal expandtab shiftwidth=4 tabstop=8 softtabstop=4
" Shell
autocmd FileType sh setlocal expandtab shiftwidth=4 tabstop=8 softtabstop=4
" Lisp
autocmd Filetype lisp,scheme setlocal equalprg=~/.vim/bin/lispindent.lisp expandtab shiftwidth=2 tabstop=8 softtabstop=2
" Ruby
autocmd FileType ruby setlocal expandtab shiftwidth=2 tabstop=2 softtabstop=2
" PHP: autocomplete
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
" PHP
autocmd FileType php setlocal noexpandtab shiftwidth=4 tabstop=4 softtabstop=4
" X?HTML & XML
autocmd FileType html,xhtml,xml setlocal expandtab shiftwidth=2 tabstop=2 softtabstop=2
" CSS
autocmd FileType css setlocal expandtab shiftwidth=4 tabstop=4 softtabstop=4
" Syntax of these languages is fussy over tabs Vs spaces (or I like em this way)
autocmd FileType make setlocal ts=8 sts=8 sw=8 noexpandtab
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
" Beautify by filetype
autocmd FileType javascript noremap <buffer> <c-f> :call JsBeautify()<cr>
autocmd FileType html noremap <buffer> <c-f> :call HtmlBeautify()<cr>
autocmd FileType css noremap <buffer> <c-f> :call CSSBeautify()<cr>
" vim-javascipt adds $ as a keyword
set iskeyword-=$
augroup phpjsfix
autocmd!
autocmd FileType javascript setlocal iskeyword+=$
autocmd FileType php setlocal iskeyword-=$
augroup END
" turn off variables for php
let g:tagbar_type_php = {
\ 'kinds' : [
\ 'i:interfaces',
\ 'c:classes',
\ 'd:constant definitions:0:0',
\ 'f:functions',
\ 'j:javascript functions',
\ ],
\ }
" javascript bundle
let g:html_indent_inctags = "html,body,head,tbody"
let g:html_indent_script1 = "inc"
let g:html_indent_style1 = "inc"
" syntastic language checkers
"let g:syntastic_javascript_checker = "closurecompiler"
"let g:syntastic_javascript_closure_compiler_path = "~/bin/closure-compiler.jar"
let g:syntastic_python_checkers=['pylint']
" vim syntax/style checking for CakePHP
" pear channel-discover pear.cakephp.org;
" pear install --alldeps cakephp/CakePHP_CodeSniffer;
let g:syntastic_php_checkers=['php', 'phpcs -p --extensions=php --standard=CakePHP', 'phpmd']
" HTML extra tads
let g:syntastic_html_tidy_blocklevel_tags = ['template']
let g:syntastic_html_tidy_empty_tags = ['span']
let g:syntastic_html_tidy_ignore_errors = ['trimming empty <span>']
" ctrlp config - persistant cache
let g:ctrlp_clear_cache_on_exit = 0
let g:ctrlp_max_height = 20
let g:ctrlp_match_window = 'bottom,order:btt,min:1,max:25,results:25'
" }
" custom shortcuts: folding {
set foldmethod=syntax
inoremap <F9> <C-O>za
nnoremap <F9> za
onoremap <F9> <C-C>za
vnoremap <F9> zf
" }
" custom shortcuts: insert mode {
" this is a sexy little shortcut to break out of insert mode
"inoremap ;; <ESC>l
nnoremap K 0YP
" }
" custom shortcuts: normal mode {
" yank to clipboard shortcut
nnoremap <leader>y "*y
" paste from clipboard shortcut
nnoremap <leader>v "*v
" ,ev edit vimrc file on the fly
nnoremap <leader>ev <C-w><C-v><C-l>:e $MYVIMRC<cr>
" ,rv reload the vimrc file on the fly
nnoremap <leader>rv :source ~/.vimrc
" surroud replace quotes
map <leader>" cs'"
map <leader>' cs"'
" wrap word in single quotes
nnoremap <leader>.' ysiw'
" wrap word in double quotes
nnoremap <leader>." ysiw"
" duplicate current word, after a colon
nnoremap <leader>.. yiwea:<SPACE><ESC>p
" ,W strip all trailing whitespace
nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<CR>
" ,a ack helper
nnoremap <leader>a :Ack
" ,ft HTML fold tag
nnoremap <leader>ft Vatzf
" ,S sort a list of CSS properties
nnoremap <leader>S ?{<CR>jV/^\s*\}?$<CR>k:sort<CR>:noh<CR>
" ,v reselect text that was just pasted
nnoremap <leader>v V`]`
" ,# set relative numbers to ruler
nnoremap <F4> :set relativenumber<cr>
nnoremap <F3> :set number<cr>
" ,Y yank in word shortcut
nnoremap <leader>Y yiw
" ,R replace in word (keep the replacement in registry)
nnoremap <leader>R viwpyiw
" ,A move to end of line, back one character, enter insert mode
nnoremap <leader>A $hi
" custom saved macros
" 1. start record `qq`
" 2. do stuff
" 3. stop recording `q` (test macro)
" 4. `:e ~/.vimrc`
" 5. `"qp` pastes the escaped macro
" 6. format as with `let @x = '...'`
" find array( .. and matching ), replace with [ ... ]
" http://screencast.com/t/1TTpJvpiuEq
let @p = '/<array\(diwma%mb`ar[`br]%'
" }