" [OPTION] {{{1 " ------------- " Fix delete for iPad ":fixdel " Encodage scriptencoding utf-8 set enc=utf-8 set fenc=utf-8 " Mode non compatible avec Vi set nocompatible " Active le mode 256 couleurs (parce qu'on l'utilise souvent en remote!) set t_Co=256 set term=screen-256color " Changer le dossier contenant les fichiers temporaires if isdirectory($HOME . '/.vim-backup') == 0 :silent !mkdir -p ~/.vim-backup >/dev/null 2>&1 endif set backupdir=~/.vim-backup/ set backup if isdirectory($HOME . '/.vim-swap') == 0 :silent !mkdir -p ~/.vim-swap >/dev/null 2>&1 endif set directory=~/.vim-swap// if exists("+undofile") if isdirectory($HOME . '/.vim-undo') == 0 :silent !mkdir -p ~/.vim-undo > /dev/null 2>&1 endif set undodir=~/.vim-undo// set undofile endif " Afficher les tabulations et les espaces highlight Tab ctermbg=darkgray guibg=darkgray highlight Space ctermbg=darkgray guibg=darkgray au BufWinEnter * let w:m2=matchadd('Tab', '\t', -1) au BufWinEnter * let w:m3=matchadd('Space', '\s\+$\| \+\ze\t', -1) set list listchars=tab:» ,trail:·,nbsp:× " Thème "colorscheme neolao_colors colorscheme molokai set cursorline set cursorcolumn " Afficher les numéros de ligne set number " Indentation set cindent "set cinoptions+={2 set autoindent set smartindent set noai sw=4 ts=4 expandtab set tabstop=4 " Le backspace set backspace=indent,eol,start " Activer la sauvegarde set backup " un historique raisonnable set history=100 " undo, pour revenir en arrière set undolevels=150 " Suffixes à cacher set suffixes=.jpg,.png,.jpeg,.gif,.bak,~,.swp,.swo,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc,.pyc,.pyo " Inclusion d'un autre fichier avec des options if filereadable(expand("~/.vimrc_local.vim")) source ~/.vimrc_local.vim endif " Activation de la syntaxe if has("syntax") syntax on endif " Quand un fichier est changé en dehors de Vim, il est relu automatiquement set autoread " Aucun son ou affichage lors des erreurs set errorbells set novisualbell set t_vb= " Quand une fermeture de parenthèse est entrée par l'utilisateur, " l'éditeur saute rapidement vers l'ouverture pour montrer où se " trouve l'autre parenthèse. Cette fonction active aussi un petit " beep quand une erreur se trouve dans la syntaxe. set showmatch set matchtime=2 " Afficher la barre d'état set laststatus=2 " Tout ce qui concerne la recherche. Incrémentale avec un highlight. " Elle prend en compte la différence entre majuscule/minuscule. set incsearch set noignorecase set infercase " Quand la rechercher atteint la fin du fichier, pas " la peine de la refaire depuis le début du fichier set hlsearch " Ne pas nous afficher un message quand on enregistre un readonly "set writeany " Afficher les commandes incomplètes set showcmd " Afficher la position du curseur set ruler " Désactiver le wrapping set nowrap " Options folding set foldenable set foldmethod=marker set foldmarker={{{,}}} " Un petit menu qui permet d'afficher la liste des éléments " filtrés avec un wildcard set wildmenu set wildignore=*.o,*#,*~,*.dll,*.so,*.a set wildmode=full " Format the statusline "set statusline=%F%m\ %r\ Line:%l\/%L,%c\ %p%% "set statusline=%<%f\ %{VCSCommandGetStatusLine()}\ %h%m%r%=%l,%c%V\ %P set laststatus=2 if has('statusline') function! SetStatusLineStyle() let &stl="" . \"%{fugitive#statusline()} " . \"%f %y " . \"%([%R%M]%)" . \"%#StatusLineNC#%{&ff=='unix'?'':&ff.'\ format'}%*" . \"%{'$'[!&list]}" . \"%{'~'[&pm=='']}" . \"%=" . \"#%n %l/%L,%c%V " . \"" endfunc call SetStatusLineStyle() if has('title') set titlestring=%t%(\ [%R%M]%) endif endif " Configuration de la souris en mode console " ="" pas de souris par défaut set mouse=a " Améliore l'affichage en disant à vim que nous utilisons un terminal rapide set ttyfast " Lazy redraw permet de ne pas mettre à jour l'écran " quand un script vim est entrain de faire une opération set lazyredraw if has("gui_running") "map "map " On cache la souris en mode gui "set mousehide " ligne de commande dans deux ligne "set ch=2 endif " faire en sorte que le raccourci CTRL-X-F " marche même quand le fichier est après " le caractère égal. Comme : " variable=/etc/ "set isfname-== " Pathogen: Gestionnaire de plugins call pathogen#infect() " }}}1 " [PLUGIN] TList : Panneau qui liste les fonctions {{{1 " ----------------------------------------------------- filetype on filetype plugin on " Indiquer le chemin de ctags "let Tlist_Ctags_Cmd = '/usr/local/bin/ctags' " Langages au BufRead,BufNewFile *.js set filetype=javascript au BufRead,BufNewFile *.as set filetype=actionscript au BufRead,BufNewFile *.css set filetype=css au BufRead,BufNewFile *.scss set filetype=scss au BufRead,BufNewFile *.php set filetype=php let tlist_javascript_settings = 'vimjavascript;c:CLASSES;p:PROPERTIES;g:GETTER/SETTER;f:METHODS' let tlist_actionscript_settings = 'vimactionscript;c:CLASSES;f:METHODS;p:PROPERTIES' let tlist_css_settings = 'vimcss;e:SECTIONS' let tlist_scss_settings = 'vimcss;e:SECTIONS' let tlist_php_settings = 'vimphp;c:CLASSES;p:PROPERTIES;f:METHODS' " Fermer Vim s'il ne reste que Tlist let Tlist_Exit_OnlyWindow = 1 " La panneau gagne le focus dès qu'il est ouvert "let Tlist_GainFocus_On_ToggleOpen = 0 " Une fois une fonction sélectionnée, on ferme le panneau let Tlist_Close_On_Select = 0 " Mettre à jour automatiquement quand un fichier est en édition let Tlist_Auto_Update = 1 " Toujours parser le fichier même si le panneau n'est pas ouvert let Tlist_Process_File_Always = 0 " Ouvrir le panneau à droite let Tlist_Use_Right_Window = 1 " Largeur du panneau let Tlist_WinWidth = 40 " Le contenu du panneau ne représente que le fichier courant let Tlist_Show_One_File = 1 " Afficher dans le menu let Tlist_Show_Menu = 1 " Replie automatiquement les fichiers inactifs let Tlist_File_Fold_Auto_Close = 1 " Persistance "autocmd TabLeave * wincmd p "autocmd TabEnter * execute ResumeTList() " }}}1 " [PLUGIN] Syntastic : Syntax checker {{{1 " ---------------------------------------- let g:syntastic_enable_signs=1 let g:syntastic_quiet_warnings=1 " }}}1 " [PLUGIN] Sources Explorer {{{1 " ------------------------------ " The switch of the Source Explorer nmap :SrcExplToggle " // Set the height of Source Explorer window let g:SrcExpl_winHeight = 8 " // Set 100 ms for refreshing the Source Explorer let g:SrcExpl_refreshTime = 100 " // Set "Enter" key to jump into the exact definition context let g:SrcExpl_jumpKey = "" " // Set "Space" key for back from the definition context let g:SrcExpl_gobackKey = "" " // In order to Avoid conflicts, the Source Explorer should know what plugins " // are using buffers. And you need add their bufname into the list below " // according to the command ":buffers!" let g:SrcExpl_pluginList = [ \ "__Tag_List__", \ "_NERD_tree_", \ "Source_Explorer" \ ] " // Enable/Disable the local definition searching, and note that this is not " // guaranteed to work, the Source Explorer doesn't check the syntax for now. " // It only searches for a match with the keyword according to command 'gd' let g:SrcExpl_searchLocalDef = 0 " // Let the Source Explorer update the tags file when opening let g:SrcExpl_isUpdateTags = 1 " // Use program 'ctags' with argument '--sort=foldcase -R' to create or " // update a tags file let g:SrcExpl_updateTagsCmd = "ctags --sort=foldcase -R ." " // Set "" key for updating the tags file artificially "let g:SrcExpl_updateTagsKey = "" " }}}1 " [PLUGIN] NERDTree {{{1 " ---------------------- " Ouvrir NERDTree à chaque fois qu'on lance vim " Et aussi à chaque fois qu'on change d'onglet " La même sidebar est réutilisée à chaque fois "autocmd VimEnter * execute ResumeNERDTree() "autocmd VimEnter * wincmd p "autocmd TabLeave * wincmd p "autocmd TabEnter * execute ResumeNERDTree() "autocmd TabEnter * wincmd p " Sous plugin nerdtree tabs let g:nerdtree_tabs_open_on_gui_startup = 1 let g:nerdtree_tabs_open_on_console_startup = 1 let g:nerdtree_tabs_smart_startup_focus = 1 let g:nerdtree_tabs_focus_on_files = 1 " Ne pas ignorer de fichiers let NERDTreeIgnore=[] " Affichier les dossiers et fichiers cachés let NERDTreeShowHidden=1 " Taille de l'explorateur let NERDTreeWinSize=30 " }}}1 " [PLUGIN] NeoComplCache {{{1 " ---------------------- " Disable AutoComplPop. let g:acp_enableAtStartup = 1 " AutoComplPop like behavior. let g:neocomplcache_enable_auto_select = 0 " Use neocomplcache. let g:neocomplcache_enable_at_startup = 1 " Use smartcase. let g:neocomplcache_smart_case = 1 " Use camel case completion. let g:neocomplcache_enable_camel_case_completion = 1 " Use underbar completion. let g:neocomplcache_enable_underbar_completion = 1 " Set minimum syntax keyword length. let g:neocomplcache_min_syntax_length = 3 " Set manual completion length. let g:neocomplcache_manual_completion_start_length = 2 " Set minimum keyword length. let g:neocomplcache_min_keyword_length = 3 " Print caching percent in statusline. let g:neocomplcache_caching_percent_in_statusline = 1 " Define dictionary. "let g:neocomplcache_dictionary_file_type_lists = { " \ 'default' : '', " \ 'vimshell' : $HOME.'/.vimshell_hist', " \ 'scheme' : $HOME.'/.gosh_completions', " \ 'actionscript' : $HOME.'/.vim/dict/actionscript.dict' " \ } " Define keyword. "if !exists('g:neocomplcache_keyword_patterns') " let g:neocomplcache_keyword_patterns = {} "endif "let g:neocomplcache_keyword_patterns['default'] = '\h\w*' "let g:neocomplcache_snippets_dir = $HOME.'/.vim/neosnippets' " }}}1 " [PLUGIN] Zend Coding {{{1 let g:user_zen_leader_key = '' " }}} 1 " AUTOCMoD {{{1 " ------------ if has("autocmd") " Détection auto du format " + activer indent filetype plugin indent on augroup divers au! " Textwidth de 78 pour tous les fichiers texte autocmd FileType text setlocal textwidth=78 " Remet la position du curseur comme elle était avant autocmd BufReadPost * \ if line("'\"") > 0 && line("'\"") <= line("$") | \ exe "normal g`\"" | \ endif " La valeur des tabs par défaut " autocmd BufNewFile,BufRead * call ChangeTabSize(4, 0) " Ne pas faire de wrap dans les fichiers ChangeLog autocmd BufNewFile,BufRead ChangeLog set nowrap textwidth=0 autocmd BufNewFile,BufRead ChangeLog call ChangeTabSize(8, 0) " PKGBUILD autocmd BufNewFile,BufRead PKGBUILD set syntax=sh augroup END augroup pdf au! autocmd BufReadPre *.pdf set ro autocmd BufReadPost *.pdf %!pdftotext -nopgbrk "%" - | fmt -csw78 augroup END " PHP " autocmd FileType php setlocal shiftwidth=8 tabstop=8 softtabstop=8 autocmd FileType php set omnifunc=phpcomplete#CompletePHP " ACTIONSCRIPT autocmd BufRead *.as set syntax=actionscript autocmd FileType actionscript set omnifunc=actionscriptcomplete#Complete " CSS autocmd BufRead *.css set syntax=css autocmd FileType css set omnifunc=csscomplete#CompleteCSS endif " }}}1 " Fonctions utilisées par vimrc {{{1 " --------------------------------- " Afficher / Cacher NERDTree let g:nerdtreeopened=1 function! ToggleNERDTree() execute(":NERDTreeToggle") if g:nerdtreeopened != 0 let g:nerdtreeopened=0 else let g:nerdtreeopened=1 endif endfunction function! ResumeNERDTree() if g:nerdtreeopened != 0 execute(":NERDTree") execute(":NERDTreeMirror") else execute(":NERDTreeClose") endif endfunction " Afficher / Cacher TList let g:tlistopened=0 function! ToggleTList() execute(":TlistToggle") if g:tlistopened != 0 let g:tlistopened=0 else let g:tlistopened=1 endif endfunction function! ResumeTList() if g:tlistopened != 0 execute(":TlistClose") execute(":TlistOpen") else execute(":TlistClose") endif endfunction " Changer la taille des tabulations function! ChangeTabSize(tab_size, expandtab) execute("set tabstop=".a:tab_size." softtabstop=".a:tab_size." shiftwidth=".a:tab_size) if a:expandtab != 0 execute("set expandtab") else execute("set noexpandtab") endif endfunction " Switcher de mode Tabulation / Espace function ToggleTab() if &expandtab set noexpandtab else set expandtab endif endfunction " Aller dans le répertoire du fichier édité. function! ChangeToFileDirectory() if bufname("") !~ "^ftp://" " C'est impératif d'avoir un fichier local ! lcd %:p:h endif endfunction " Switcher de mode normal / hexadecimal function ToggleHex() " hex mode should be considered a read-only operation " save values for modified and read-only for restoration later, " and clear the read-only flag for now let l:modified=&mod let l:oldreadonly=&readonly let &readonly=0 let l:oldmodifiable=&modifiable let &modifiable=1 if !exists("b:editHex") || !b:editHex " save old options let b:oldft=&ft let b:oldbin=&bin " set new options setlocal binary " make sure it overrides any textwidth, etc. let &ft="xxd" " set status let b:editHex=1 " switch to hex editor %!xxd else " restore old options let &ft=b:oldft if !b:oldbin setlocal nobinary endif " set status let b:editHex=0 " return to normal editing %!xxd -r endif " restore values for modified and read only state let &mod=l:modified let &readonly=l:oldreadonly let &modifiable=l:oldmodifiable endfunction " }}}1 " Raccourcis clavier {{{1 " ----------------------- " F2 : Désactiver le highlight (lors d'une recherche par exemple) map :let @/="" " F5 : Cacher les @todo map :cclose imap " F6 : Afficher les @todo map :grep -r --exclude=*~ --exclude=*.swp "@todo" * :copen imap " F7 : [PLUGIN] NERDTree map :execute ToggleNERDTree() imap vmap map :NERDTreeFind imap vmap " F8 : [PLUGIN] TList map :execute ToggleTList() imap vmap " F9 : Switcher de mode tabulation / espace map mz:execute ToggleTab() imap mz:execute ToggleTab()i " F10 : [PLUGIN] Syntastic "map :SyntasticEnable "imap :SyntasticEnable "vmap :SyntasticEnable " Onglets map :tabnew imap vmap "map :tabclose "imap "vmap noremap :tabnext map , :tabprevious map :tabprevious " Auto insert "map a ia "map d id "map e ie "map h ih "map j ij "map k ik "map l il "map r ir "map u iu "map z iz " [PLUGIN] NeoComplCache "imap neocomplcache#sources#snippets_complete#expandable() ? "\(neocomplcache_snippets_expand)" : pumvisible() ? "\" : "\" " Supprimer une ligne map :delete imap :startinsert " Déplacer la ligne vers le haut map :.move .-2 imap :startinsert " Déplacer la ligne vers le bas map :.move .+1 imap :startinsert " Déplacer les lignes vers le haut vmap :move '<-2gv " Déplacer les lignes vers le bas vmap :move '>+1gv " Dupliquer la ligne vers le haut "map :.copy .-1 "inoremap :.copy .-1:startinsert " Dupliquer la ligne vers le bas map :.copy . imap :startinsert " Dupliquer les lignes vers le haut vmap :copy '>gv " Dupliquer les lignes vers le bas vmap :copy '<-1gv " Memorise la position du curseur: mz " Aller à l'ancienne position du curseur: `z " Autocomplétion "imap "imap "imap " Déplacer d'un mot imap wi "map w imap bi "map b " Indenter "map gv> " Annuler map :undo imap vmap " Sélectionner tout map ggVG imap vmap " Copier (le gv c'est pour remettre le sélection) "map "+ygv " Couper "map "+x " Coller "map "+gP " Encoder/Décoder rapidement "map ,c ggVGg? " Entrer la commande ":e" dans le répertiore du fichier édité if has("unix") map ,e :e =expand("%:p:h") . "/" else map ,e :e =expand("%:p:h") . "\" endif " }}}1 " " vim:ai:et:sw=4:ts=4:sts=4:tw=78:fenc=utf-8:foldmethod=marker