-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy path.vimrc
213 lines (171 loc) · 6.72 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
" .vimrc by Tobias Schlitt <[email protected]>.
" No copyright, feel free to use this, as you like, as long as you keep some
" credits.
"
" General VIM settings file. Optimized for coding PHP can be found in
" ~/vim/ftdetect/php.vim.
"
" v1.1pl1
"
" Changelog:
"
" v1.1:
" --------------
" - Added versioning and changelog
" - Added auto-completion using <TAB>
" - Added auto-reload command, when .vimrc changes
" - Deactivated <CTRL>-p => "pear package" in favor of
" - Mapped <CTRL>-p => "run through CLI"
" - Added fold markers for better overview
" - Added for mapping for wrapping visual selections into chars (like '/(/...)
" - Added scrolljump=5 and scrolloff=3 for better moving around with folds
" - Added mapping <CTRL>-h to search for the word under the cursor (should be
" a funcion) using phpm
" - Replaced map/imap with noremap/inoremap for clearer mappings
"
" v1.1pl1:
" --------------
" - Fixed issue with <CTRL>-p for running PHP CLI (missing <cr>)
" - Remapped PHP compile check to ; (in command mode only)
"
" v1.2:
" -----
" - Remapped PHP compile check to . (in command mode only)
" - Mapped ; to (add ; at the end of line, when missing - command mode only)
" - Added make facilities (:make, jump to error).
" - Added setting for not highlighting every search result (nohlsearch).
" - Added laststatus=2 (tipp by Derick)
" - Tip by Jakob (UG): Visual, <z>, <f> == foldmarkers for area
" - Moved PHP specific settings to .vim/ftdetect/php.vim
" - Activated sourcing of ftplugins
" - Added file type setting for .phps files
" - Created PDV (phpDocumentor for VIM) and added mapping (ATTENTION! BC
" break!)
" - Fixed bug with cover char mapping of "" in visual mode
" - Added possible alternatives for other coding standards
"
" - Replace grepprg to remove SVN results
" - Add mapping for VIM7 spell checks to <F5>
" - Added autocommand to highlight the current line in insert mode.
" - Added skeleton file to be read for new PHP files.
" Delete all auto commands (needed to auto source .vimrc after saving)
autocmd!
" Load and initialize Pathogen bundle management
" Disabling filetype detection first is needed on some linux distros.
" see http://www.adamlowe.me/2009/12/vim-destroys-all-other-rails-editors.html
filetype off
call pathogen#infect('bundles')
filetype plugin indent on
" Color settings
set t_Co=256
let g:CSApprox_attr_map = { 'bold' : 'bold', 'italic' : '', 'sp' : '' }
set background=light
colorscheme solarized
let g:snippets_dir = "~/.vim/snippets"
" Set new grep command, which ignores SVN!
" TODO: Add this to SVN
set grepprg=/usr/bin/vimgrep\ $*\ /dev/null
" Map <F5> to turn spelling on (VIM 7.0+)
map <F5> :setlocal spell! spelllang=en_us<cr>
" Map <F6> to turn spelling (de) on (VIM 7.0+)
map <F6> :setlocal spell! spelllang=de<cr>
" Highlight current line in insert mode.
autocmd InsertLeave * set nocursorline
autocmd InsertEnter * set cursorline
" Reads the skeleton php file
" Note: The normal command afterwards deletes an ugly pending line and moves
" the cursor to the middle of the file.
autocmd BufNewFile *.php 0r ~/.vim/skeleton.php | normal Gdda
" Reads the skeleton txt file
autocmd BufNewFile *.txt 0r ~/.vim/skeleton.txt | normal GddOAOAOAOAOAOAOAOAOA
autocmd BufNewFile *.rst 0r ~/.vim/skeleton.txt | normal GddOAOAOAOAOAOAOAOAOA
" Disable phpsyntax based indenting for .php files {{{
au BufRead,BufNewFile *.php set indentexpr= | set smartindent
" }}}
" {{{ .phps files handled like .php
au BufRead,BufNewFile *.phps set filetype=php
" }}}
" {{{ Settings
" Show nice info in ruler
set ruler
set laststatus=2
" Set standard setting for PEAR coding standards
set tabstop=4
set shiftwidth=4
" Show line numbers by default
set number
" Enable folding by fold markers
set foldmethod=marker
" Autoclose folds, when moving out of them
set foldclose=all
" Use incremental searching
set incsearch
" Do not highlight search results
set nohlsearch
" Jump 5 lines when running out of the screen
set scrolljump=5
" Indicate jump out of the screen when 3 lines before end of the screen
set scrolloff=3
" Repair wired terminal/vim settings
set backspace=start,eol,indent
" Allow file inline modelines to provide settings
set modeline
" MovingThroughCamelCaseWords
nnoremap <silent><C-Left> :<C-u>cal search('\<\<Bar>\U\@<=\u\<Bar>\u\ze\%(\U\&\>\@!\)\<Bar>\%^','bW')<CR>
nnoremap <silent><C-Right> :<C-u>cal search('\<\<Bar>\U\@<=\u\<Bar>\u\ze\%(\U\&\>\@!\)\<Bar>\%$','W')<CR>
inoremap <silent><C-Left> <C-o>:cal search('\<\<Bar>\U\@<=\u\<Bar>\u\ze\%(\U\&\>\@!\)\<Bar>\%^','bW')<CR>
inoremap <silent><C-Right> <C-o>:cal search('\<\<Bar>\U\@<=\u\<Bar>\u\ze\%(\U\&\>\@!\)\<Bar>\%$','W')<CR>
" }}}
" Toggle paste with <ins>
set pastetoggle=<ins>
" Go to insert mode when <ins> pressed in normal mode
nnoremap <silent> <ins> :setlocal paste!<CR>i
" Switch paste mode off whenever insert mode is left
autocmd InsertLeave <buffer> se nopaste
" Source .vimrc after saving .vimrc
autocmd bufwritepost .vimrc source $MYVIMRC
" Twig template highlighting
autocmd BufRead *.twig set filetype=twig
autocmd BufRead *.html.twig set filetype=htmltwig
" VIMTips
let g:vimtip_tips = []
call add(g:vimtip_tips, "Register <*> is middle mouse clipboard")
call add(g:vimtip_tips, "Search in pman: <SHIFT>+<k>")
call add(g:vimtip_tips, "Jump to matching brace: <%>")
call add(g:vimtip_tips, "Re-indent code: <=>")
call add(g:vimtip_tips, "Indent inner / outer block: >iB / >aB")
call add(g:vimtip_tips, "Snip complete: cls, if, fn, fe, fi")
call add(g:vimtip_tips, "\\c in Such-Regex = case-insensitive")
call add(g:vimtip_tips, ":r <file> paste the given file at the current position")
autocmd VimEnter * call vimtip#NextTip()
autocmd WinEnter * call vimtip#NextTip()
" Undo history between sessions
set undodir=~/.vim/undodir
set undofile
set undolevels=1000 "maximum number of changes that can be undone
set undoreload=10000 "maximum number lines to save for undo on a buffer reload
" Colored column (to see line size violations)
set colorcolumn=80
" Show large "menu" with auto completion options
set wildmenu
set wildmode=list:longest
" Visual "beep" if something goes wrong
set visualbell
" Do not queue multple belil
set t_vb=
" Bigger block size for faster scrolling
set ttyfast
"set listchars=tab:▸\ ,eol:¬
"set list " Activate display of invisibles by default
" Write with sudo ":w!!"
cnoremap w!! w !sudo tee % >/dev/null
" inoremap <CR> <CR><Esc>:call RemoveTrailingWhitespace()<CR>i
func! RemoveTrailingWhitespace()
let l:lastline = line(".") - 1
call setline(l:lastline, substitute(getline(l:lastline), ' \+$', '', ''))
endfunc
" TODO: Yank last command output to certain register
" Source local settings -- this should always be the LAST thing to do in here!
if filereadable($HOME . "/.vimlocalrc")
source ~/.vimlocalrc
endif