" Initialize some variables
let mapleader = "_"
" General {{{
" Tell vim to look for these directories when doing gf :find , see :h path
set path+=libs/skyobjects,include
"set define=^function
" set some tag files generated from ctags -R [dir_to_project]
" this is mandatory for omni completion of user defined classes, methods, functions
" see :h new-omni-completion
set tags=~/.vim/tags/nakama
" make dictionary completion source part of the default completion sources
set complete-=k complete+=k
set dictionary+=~/.vim/dictionary/funclist.txt
set fileencodings=latin1
set encoding=latin1
set termencoding=utf-8
set hidden
set lz " do not redraw while running macros (much faster) (LazyRedraw)
set infercase
set backup
set backupdir=~/.vim/backup
set writebackup
set mouse=a
set ww=b,s,<,>
" }}}
" Visual options {{{
set showmatch
set nonu
set nohls
set ruler
set vb
set wildmenu
set wildmode=list:longest,full
" }}}
" Text formatting {{{
set shiftwidth=4
set softtabstop=4
set tabstop=4
set expandtab
set bs=2
set textwidth=0
set ai
set ignorecase
set foldmethod=marker
set nofoldenable
" }}}
" Vim UI {{{
set showcmd
set showmode
"set verbose=9
" }}}
" Theme/Colors {{{
syntax on
set background=dark
" }}}
" Global variables {{{
" }}}
" Autocommands {{{
:augroup my_tab
if !exists("autocommands_loaded")
let autocommands_loaded = 1
au BufNewFile,BufRead *.php set shiftwidth=4 softtabstop=4 tabstop=4
au BufNewFile,BufRead *.html set shiftwidth=2 softtabstop=2 tabstop=2
au BufNewFile,BufRead *.css set shiftwidth=2 softtabstop=2 tabstop=2 omnifunc=csscomplete#CompleteCSS
au BufNewFile,BufRead *.js set shiftwidth=4 softtabstop=4 tabstop=4
au BufNewFile,BufRead *.tpl set shiftwidth=2 softtabstop=2 tabstop=2
au BufNewFile,BufRead *.tpl :set ft=html " all my .tpl files ARE html
au BufNewFile,BufRead *.phtml :set ft=php " all my .phtml files ARE php
endif
" }}}
" Mappings {{{
" Quicker way the call the svncommand.vim :SVNVimDiff command than the default
" <Leader>svd mapping
nmap <Leader>vd :SVNVimDiff<Enter>
" Execute file within vim
nmap <F12> :call ExecFile()<Enter>
" Call phpdoc
map <C-P> :call PhpDocSingle()<CR>
" Toggle mouse on or off
map <C-m> :call ToggleActiveMouse()<CR>
" call the taglist window
"map <C-t> :Tlist<Enter>
" A quicker way to call the macro a
map <F2> @a
" Insert php tags when editing a new php file
map <F3> i<?php ?><Esc>hi
" Surround visual selection with <p> </p> if surround_tag is not defined
if !exists("surround_tag")
let surround_tag = 'p'
endif
vnoremap <F4> :call Surround('<' . surround_tag . '>', '</' . surround_tag . '>')<CR>
" A quick way to comment lines with the FeralToggleCommentify.vim plugin
map <F8> :TC<CR>j
" Switch to the previous buffer
map <F9> :b!#<Enter>
" Control-s seems to be universal for saving files
" and also quicker than :w<enter>
map <C-s> :w<enter>
" Switch to next same filetype buffer
nmap <Leader><Tab> :BufNextSameFT<Enter>
" Switch to previous same filetype buffer
nmap <Leader><S-Tab> :BufPrevSameFT<Enter>
" Switch to the next buffer
nmap <Tab> :bn<Enter>
" Switch to the previous buffer
nmap <S-Tab> :bp<Enter>
" Quicker way to delete a buffer
map <del> :bd<Enter>
" Press {, (, [ and it will insert the corresponding {, (, [
inoremap {{ {<cr>}<esc>kA<cr>
inoremap (( ()<esc>i
inoremap [[ []<esc>i
" Escape a word with backquotes, useful for MySQL field names
inoremap `` <esc>bi`<esc>ea`
" Opens lynx and search php.net for the word under the cursor
nmap ^L :!lynx -accept_all_cookies http://fr2.php.net/^R^W\#function.^R^W<CR>
" }}}
" Useful abbrevs {{{
iab id_skyanute id_skynaute
ab xr print_r($
ab vr var_dump($
ab fu function
ab xhtml <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"<CR>"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><CR><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr"><CR><head><CR><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-15" /><CR><title></title><CR></head><CR><body><CR></body><CR></html>
ab xhtmlxml <?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-15\"?>\n"; ?><CR><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"<CR>"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><CR><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr"><CR><head><CR><title></title><CR></head><CR><body><CR></body><CR></html>
ab html401 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"<CR>"http://www.w3.org/TR/html4/strict.dtd"><CR><html><CR><head><CR><title></title><CR></head><CR><body></body><CR></html>
ab xcss <style type="text/css"><CR>/* <![CDATA[ */<CR><CR>/* ]]> */<CR></style>
ab xjs <script type="text/javascript"><CR>/* <![CDATA[ */<CR><CR>/* ]]> */<CR></script>
ab xlinkcss <link rel="stylesheet" href="css/global.css" />
ab xlinkjs <script type="text/javascript" href="js/global.css"></script>
ab xborder border: 1px solid red;
ab xback background-color: blue;<CR>opacity: 0.8;
ab xbgimg background: #000 url() top left;
ab ftext <input type="text" name="" value="" />
ab ffile <input type="file" name="" value="" />
ab fpassword <input type="password" name="" value="" />
ab fradio <input type="radio" name="" value="" />
ab fcheckbox <input type="checkbox" name="" value="" />
ab fsubmit <input type="submit" value="Valider" />
ab fbutton <input type="button" value="" />
ab ftextarea <textarea cols="20" rows="20" name=""><CR></textarea>
ab fselect <select name=""><CR><Tab><option value=""></option><CR></select>
ab fform <form action="" method="post" enctype="multipart/form-data">
ab xhref <a href=""<CR><TAB><TAB>onclick="window.open(this.href); return false;"></a>
ab xflash <object type="application/x-shockwave-flash" id="f" data="/flash/home.swf"><CR><param name="movie" value="/flash/home.swf" /><CR><param name="quality" value="high" /><CR><param name="bgcolor" value="#ffffff" /><CR></object>
ab xobject <object type="application/x-oleobject" width="284" height="236" data=""><CR><param name="movie" value="" /><CR><param name="quality" value="high" /><CR><param name="bgcolor" value="#000000" /><CR><embed type="video/x-ms-asf-plugin" width="284" height="236" pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/" src="" name="MediaPlayer" ShowStatusBar="0" ShowControls="0"></embed><CR></object>
" }}}
" Plugin configuration {{{
" vtreeexplore
let treeExplVertical = 1
let treeExplWinSize = 30
noremap t :VSTreeExplore<Enter>
" matchit
filetype plugin on
" svncommand
" Deletes the svncommand scratch buffer when it is hidden
let g:SVNCommandDeleteOnHide = 1
" Show a special status line for a svncommand scratch buffer
set statusline=%<%f\ %{SVNGetStatusLine()}\ %h%m%r%=%l,%c%V\ %P
" minibuf
let g:miniBufExplUseSingleClick = 1
let g:miniBufExplVSplit = 1
let g:miniBufExplMinSize = 20
let g:miniBufExplMaxSize =25
" Taglist
let g:Tlist_Use_Horiz_Window = 0
let g:Tlist_Use_Right_Window = 1
let Tlist_Auto_Highlight_Tag = 0
let Tlist_Auto_Open = 0
let Tlist_Show_One_File = 1
let Tlist_Sort_Type = 'name'
" }}}
" User functions {{{
fun! Surround(s1, s2) range
exe "normal vgvmboma\<ESC>"
normal `a
let lineA = line(".")
let columnA = col(".")
normal `b
let lineB = line(".")
let columnB = col(".")
"exchange marks
if lineA > lineB || lineA <= lineB && columnA > columnB
" save b in c
normal mc
" store a in b
normal `amb
" set a to old b
normal `cma
endif
exe "normal `ba" . a:s2 . "\<ESC>`ai" . a:s1 . "\<ESC>"
endfun
function! ToggleActiveMouse()
if &mouse == "a"
exe "set mouse="
echo "Mouse is off"
else
exe "set mouse=a"
echo "Mouse is on"
endif
endfunction
"Get the next or previous buffer which matches pattern,
"wraps around end/start.
func! IncrBufFiltered(pat, decr)
let fblist =
\ filter(range(1, bufnr('$')),
\ 'buflisted(v:val) && bufname(v:val) =~ a:pat')
if empty(fblist) || len(fblist) <= 1
return bufnr('%')
endif
if a:decr == 1
let fblist = reverse(fblist)
endif
let key = index(fblist, bufnr('%')) + 1
if key >= len(fblist)
let key = 0
endif
return fblist[key]
endfun
" Execute the current file trough the appropriate interpreter
function! ExecFile()
if &ft == 'ruby'
:w
:!ruby %
elseif &ft == 'php'
:w
:!php %
else
:w
:!./%
endif
endfunction
" }}}
" User commands or aliases
command! BufNextSameFT exe "bu " . IncrBufFiltered('\.' . expand('%:e') . '$', 0)
command! BufPrevSameFT exe "bu " . IncrBufFiltered('\.' . expand('%:e') . '$', 1)