Created
March 3, 2012 12:47
-
-
Save oxyc/1965927 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/vimrc b/vimrc | |
index c90fb0c..a81f505 100644 | |
--- a/vimrc | |
+++ b/vimrc | |
@@ -14,7 +14,7 @@ call pathogen#infect() | |
set shiftwidth=2 " auto-indent amount when using cindent, etc | |
set softtabstop=2 " how many spaces is a tab | |
-set tabstop=4 " real tabs should be 4 | |
+set tabstop=2 " real tabs should be 4 | |
set expandtab " no real tabs | |
set autoindent | |
set smartindent | |
@@ -41,7 +41,7 @@ set gdefault " Add the g flag to search/rep | |
set backupdir=~/.vim/backup " backup directory | |
set directory=~/.vim/swap " swap directory | |
-set dictionary+=~/.vim/dict.txt " custom auto-complete dictionary | |
+set dictionary+=~/.vim/dictionaries/dictionary " custom auto-complete dictionary | |
" } | |
" Vim UI { | |
@@ -83,7 +83,7 @@ set virtualedit=block " Allow moving to unexisting l | |
set foldlevelstart=0 | |
set foldmarker={,} " fold C style code | |
set foldmethod=marker " fold based on indent | |
-set foldlevel=1 " don't autofold | |
+set foldlevel=0 " don't autofold | |
set foldnestmax=10 " deepest fold is 10 | |
set foldopen=block,hor,mark,percent,quickfix,tag " what movements open folds | |
@@ -96,7 +96,37 @@ vnoremap <space> zA | |
nnoremap zO zCzO | |
" Use ,z to focus the current fold | |
-nnoremap <leader>z zMzvzz | |
+nnoremap <leader>z zMzv | |
+ | |
+" } | |
+" Configurations { | |
+ | |
+let g:php_sql_query=1 " Highlight SQL queries expressed in strings | |
+let g:php_htmlInStrings=1 "Highlight HTML expressed in strings | |
+let g:php_folding=1 | |
+let g:PHP_vintage_case_default_indent=1 "Indent switch case and default | |
+ | |
+let g:syntastic_enable_signs=1 " Use :sign interace to mark syntax errors | |
+let g:syntastic_check_on_open=1 "Check for errors on buffer load | |
+let g:syntastic_auto_loc_list=1 "Open Error window automatically | |
+let g:syntastic_auto_jump=1 " Automatically jump to first detected error | |
+let g:syntastic_stl_format = '[%E{Error 1/%e: line %fe}%B{, }%W{Warning 1/%w: line %fw}]' | |
+ | |
+let g:gist_open_browser_after_post=1 | |
+ | |
+" Fix matchpairs for PHP (for matchit.vim plugin) | |
+" http://zmievski.org/files/talks/vancouver-2007/vim-for-php-programmers.pdf | |
+if exists("loaded_matchit") | |
+ let b:match_skip = 's:comment\|string' | |
+ let b:match_words = '<?\(php\)\?:?>,\<switch\>:\<endswitch\>,' . | |
+ \ '\<if\>:\<elseif\>:\<else\>:\<endif\>,' . | |
+ \ '\<while\>:\<endwhile\>,\<do\>:\<while\>,' . | |
+ \ '\<for\>:\<endfor\>,\<foreach\>:\<endforeach\>' . | |
+ \ '<\@<=[ou]l\>[^>]*\%(>\|$\):<\@<=li\>:<\@<=/[ou]l>,' . | |
+ \ '<\@<=dl\>[^>]*\%(>\|$\):<\@<=d[td]\>:<\@<=/dl>,' . | |
+ \ '<\@<=\([^/?][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>,' . | |
+ \ '<:>' | |
+endif | |
" } | |
" GUI / Looks { | |
@@ -129,16 +159,20 @@ au VimResized * exe "normal! \<c-w>=" | |
" Custom key mappings { | |
let mapleader = "," | |
-map nt :NERDTreeToggle<cr> | |
map å *<C-o> | |
map <silent> ö ^ | |
map <silent> ä $ | |
map <silent> Å <C-]> | |
-nnoremap <C-e> 3<C-e> | |
-nnoremap <C-y> 3<C-y> | |
+nnoremap <C-e> 5<C-e> | |
+nnoremap <C-y> 5<C-y> | |
map <C-l> :bnext<cr> | |
map <C-h> :bprev<cr> | |
+nnoremap <leader>p :set invpaste paste?<cr> | |
+noremap <leader>W :w !sudo tee % > /dev/null<CR> | |
+" Visual shifting without exiting visual mode | |
+vnoremap < <gv | |
+vnoremap > >gv | |
" Align text | |
nnoremap <leader>Al :left<cr> | |
@@ -162,6 +196,11 @@ au BufWinEnter * silent! loadview " make vim load view state,folds,cursor,etc | |
au FileType stylus setlocal shiftwidth=2 softtabstop=2 tabstop=2 | |
au FileType php setlocal shiftwidth=2 softtabstop=2 tabstop=2 | |
+ | |
+" @TODO | |
+"match UsingWS /\v^\ +/ | |
+"match TrailingWS /\s+$)/ | |
+ | |
" Make sure Vim returns to the same line when you reopen a file. | |
" By Amit | |
augroup line_return | |
@@ -172,21 +211,37 @@ augroup line_return | |
\ endif | |
augroup END | |
+function! SetWPConfig () | |
+ if &filetype == 'php' | |
+ setlocal shiftwidth=4 softtabstop=4 tabstop=4 | |
+ setlocal noexpandtab | |
+ setlocal nolist | |
+ endif | |
+endfunction | |
+ | |
+function! SetDrupalConfig () | |
+ if &filetype == 'php' | |
+ setlocal shiftwidth=2 softtabstop=2 tabstop=2 expandtab | |
+ setlocal listchars=tab:▸\ ,trail:· | |
+ setlocal dictionary+=~/.vim/dictionaries/drupal7 | |
+ endif | |
+endfunction | |
+ | |
+" Wordpress files | |
+au BufRead,BufNewFile */wp-content/* call SetWPConfig() | |
+ | |
" Drupal files | |
augroup module | |
au BufRead,BufNewFile *.module set filetype=php | |
au BufRead,BufNewFile *.install set filetype=php | |
au BufRead,BufNewFile *.test set filetype=php | |
+ au BufRead,BufNewFile */sites/all/* call SetDrupalConfig() | |
augroup END | |
augroup css | |
"Sort CSS attributes alphabetically | |
"Stolen from https://bitbucket.org/sjl/dotfiles/src/tip/vim/.vimrc | |
au BufNewFile,BufRead *.less,*.css nnoremap <buffer> <leader>S ?{<CR>jV/\v^\s*\}?$<CR>k:sort<CR>:noh<CR> | |
- | |
- " Make {<cr> insert a pair of brackets in such a way that the cursor is correctly | |
- " positioned inside of them AND the following code doesn't get unfolded. | |
- "au BufNewFile,BufRead *.less,*.css inoremap <buffer> {<cr>{}<left><cr><space><space><cr><esc>kA | |
augroup END | |
au BufNewFile,BufRead *.js setf javascript | |
@@ -200,10 +255,6 @@ au FileType html,php nnoremap <buffer> <s-cr> vit<esc>a<cr><esc>vito<esc>i<cr><e | |
" } | |
" Plugins { | |
-" Syntastic | |
-let g:syntastic_enable_signs=1 | |
-let g:syntastic_stl_format = '[%E{Error 1/%e: line %fe}%B{, }%W{Warning 1/%w: line %fw}]' | |
- | |
" Ack | |
map <leader>a :Ack! | |
@@ -225,4 +276,72 @@ function! StripWhitespace () | |
endfunction | |
noremap <leader>ss :call StripWhitespace ()<CR> | |
+" When you're working remotely and need to copy something to your clipboard | |
+function! ToggleCopyMode () | |
+ if &mouse == 'a' |set mouse=|else |set mouse=a|endif | |
+ set number! | |
+ set list! | |
+endfunction | |
+nnoremap <leader>c :call ToggleCopyMode ()<cr> | |
+ | |
+function! TrackTime (...) | |
+ let command = (a:0 > 0) ? a:1 : '' | |
+ exec ':! track ' . command | |
+endfunction | |
+ | |
+function! TrackShow (...) | |
+ exec ':! track --show ' . a:1 | |
+endfunction | |
+ | |
+function! TrackFind (...) | |
+ let regex = (a:0 > 0) ? a:1 : '' | |
+ exec ':! track --find ' . regex | |
+endfunction | |
+ | |
+noremap <leader>tt :call TrackTime (input("Message: "))<CR> | |
+noremap <leader>ts :call TrackShow (input("Count: "))<CR> | |
+noremap <leader>tf :call TrackShow (input("Regex: "))<CR> | |
+ | |
+function! DrupalImplementsComment () | |
+ let filename = bufname("%") | |
+ let dot = stridx(filename, ".") | |
+ let module = strpart(filename, 0, dot) | |
+ let current_line = getline(".") | |
+ let hook_idx = matchend(current_line, "function " . module . "_") | |
+ if !empty(module) && hook_idx != -1 | |
+ let hook_length = match(current_line, "(") - hook_idx | |
+ let hook_name = strpart(current_line, hook_idx, hook_length) | |
+ call DoxygenComment ("Implements hook_" . hook_name . "().") | |
+ else | |
+ call DoxygenComment () | |
+ endif | |
+endfunction | |
+ | |
+function! DoxygenComment (...) | |
+ set paste | |
+ let message = (a:0 > 0) ? a:1 : '' | |
+ exe "normal! O/**\<CR>" | |
+ \ . " * " . message . "\<CR>" | |
+ \ . " */\<Esc>" | |
+ if empty(message) | |
+ -1 | startinsert! | |
+ else | |
+ +1 | |
+ endif | |
+ set nopaste | |
+endfunction | |
+noremap <leader>dc :call DoxygenComment ()<CR> | |
+noremap <leader>di :call DrupalImplementsComment ()<CR> | |
+ | |
+" Insert <Tab> or complete identifier if the cursor is after a keyword character | |
+function MyTabOrComplete() | |
+ let col = col('.')-1 | |
+ if !col || getline('.')[col-1] !~ '\k' | |
+ return "\<tab>" | |
+ else | |
+ return "\<C-N>" | |
+ endif | |
+endfunction | |
+inoremap <Tab> <C-R>=MyTabOrComplete()<CR> | |
+ | |
" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment