""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " General """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" set nocompatible " get out of horrible vi-compatible mode filetype indent plugin on | syn on set history=1000 " How many lines of history to remember set cf " enable error files and error jumping set ffs=unix,dos,mac " support all three, in this order set viminfo+=! " make sure it can save viminfo set isk+=_,@,- " none of these should be word dividers, so make them not be set nobackup set completeopt=longest,menuone,preview inoremap pumvisible() ? "\" : "\u\" inoremap pumvisible() ? '' : \ '=pumvisible() ? "\Down>" : ""' inoremap pumvisible() ? '' : \ '=pumvisible() ? "\Down>" : ""' """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Theme/Colors """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" syntax on " syntax highlighting on set background=dark set t_Co=256 colorscheme desert "colorscheme xoria256 "let g:solarized_termcolors=256 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Vim UI """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" set wildmenu " turn on wild menu set ruler " Always show current positions along the bottom set number " turn on line numbers set lz " do not redraw while running macros (much faster) (LazyRedraw) set hid " you can change buffer without saving set backspace=eol,start,indent " make backspace work normal set whichwrap+=<,>,h,l " backspace and cursor keys wrap to set shortmess=atI " shortens messages to avoid 'press a key' prompt set report=0 " tell us when anything is changed via :... " make the splitters between windows be blank set fillchars=vert:\ ,stl:\ ,stlnc:\ """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Visual Cues """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" set showmatch " show matching brackets set mat=5 " how many tenths of a second to blink matching brackets for set nohlsearch " highlight searched for phrases set incsearch " do highlight as you type you search phrase set listchars=tab:\|\ ,trail:.,extends:>,precedes:<,eol:$ " what to show when I hit :set list set so=10 " Keep 10 lines (top/bottom) for scope set novisualbell " don't blink set noerrorbells " no noises set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%04l,%04v][%p%%] set laststatus=2 " always show the status line """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Text Formatting/Layout """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" set fo=tcrqn " See Help (complex) set ai " autoindent set si " smartindent set tabstop=4 " tab spacing (settings below are just to unify it) set softtabstop=4 " unify set shiftwidth=4 " unify set expandtab " space instead of tabs set smarttab "Use the "shiftwidth" setting for inserting s instead of the "tabstop" setting, when at the beginning of a line. set nowrap " do not wrap lines """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Mouse Settings """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" set mouse=a " mouse support in all modes set mousehide " hide the mouse when typing text " ,p and shift-insert will paste the X buffer, even on the command line nmap p i imap cmap " map to clear search nmap :nohlsearch " this makes the mouse paste a block of text without formatting it " (good for code) map "*p " Convenient for non italian keyboard map ò : """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Matchit """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" let b:match_ignorecase = 1 " make tab in v mode ident code vmap >gv vmap I nmap ^i "Easy to access esc key map! map " paste mode - this will avoid unexpected effects when you " cut or copy some text from one window and paste it in Vim. set pastetoggle= """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Perl """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" let perl_extended_vars=1 " highlight advanced perl vars inside strings """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Custom Functions """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "switch spellcheck languages let g:myLangList = [ "none", "it", "en_us" ] function! MySpellLang() "loop through languages if !exists( "b:myLang" ) let b:myLang=0 endif let b:myLang = b:myLang + 1 if b:myLang >= len(g:myLangList) | let b:myLang = 0 | endif if b:myLang== 0 | setlocal spell nospell | endif if b:myLang== 1 | setlocal spell spelllang=it | endif if b:myLang== 2 | setlocal spell spelllang=en_us | endif echo "language spell:" g:myLangList[b:myLang] endfunction """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Mappings """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " alt-i (normal mode) inserts a single char, and then switches back to normal map i r " set F4 to toogle number/nonumber map :set invnumber " encypt the file (toggle) map ggVGg? map :call MySpellLang() " Map NERDTree show and hide map :NERDTreeToggle imap :NERDTreeToggle " Tagbar toggle map :TagbarToggle imap :TagbarToggle " Alt-right/left to navigate forward/backward in the tags stack map map """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Autocommands """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" if has ("autocmd") " Enable file type detection ('filetype on'). " Syntax of these languages is fussy over tabs Vs spaces autocmd FileType make setlocal ts=8 sts=8 sw=8 noexpandtab autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab " Customisations based on house-style (arbitrary) autocmd FileType html setlocal ts=2 sts=2 sw=2 expandtab autocmd FileType css setlocal ts=2 sts=2 sw=2 expandtab " Treat sh correctly autocmd FileType sh setlocal ts=4 sts=4 sw=4 expandtab " Treat .rss files as XML autocmd BufNewFile,BufRead *.rss,*.atom setfiletype xml autocmd FileType c,cpp,slang set cindent autocmd FileType c,cpp,slang set textwidth=79 autocmd FileType c,cpp,slang set tags=./tags,/usr/src/linux/tags,~/.vim/tags/usr/include/tags autocmd BufEnter * :syntax sync fromstart " ensure every file does syntax highlighting (full) autocmd BufNewFile *.sh call append(0, "#!/bin/bash") autocmd BufNewFile *.pl call append(0, "#!/usr/bin/perl") autocmd BufNewFile *.py call append(0, "#!/bin/python") " PHP documenter script bound to Control-P autocmd FileType php inoremap :call PhpDocSingle()i autocmd FileType php nnoremap :call PhpDocSingle() autocmd FileType php vnoremap :call PhpDocRange() " When editing a file, always jump to the last known cursor position. " Don't do it when the position is invalid or when inside an event handler " (happens when dropping a file on gvim). autocmd BufReadPost * \ if line("'\"") > 0 && line("'\"") <= line("$") | \ exe "normal g`\"" | \ endif endif """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " General configs """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" set titlestring=%t%(\ %M%)%(\ (%{expand(\"%:~:h\")})%)%(\ %a%)\ -\ %{v:servername} if &term == "screen" set t_ts=^[k set t_fs=^[\ endif if &term == "screen" || &term == "xterm" set title endif """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Plugin activation """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " vim-addon-manager " let vam_install_path = expand('$HOME') . '/.vim/addons' exec 'set runtimepath+='.vam_install_path.'/vim-addon-manager' " Enable addons with vim-addon-manager using file type recognition let ft_addons = { \ 'always': ['desert', 'gnupg', 'surround', 'checksyntax', 'quickfixsigns', 'LargeFile', 'snipmate', 'snipmate-snippets', 'The_NERD_tree', 'SuperTab%1643', 'fugitive'], \ 'r': [ 'Screen_vim__gnu_screentmux', 'Vim-R-plugin' ], \ '^\%(c\|cpp\|javascript\|python\|php\|html\|xml\|r\|sh\|css\|java\|make\|xslt\|vim\)$': [ 'Tagbar', 'checksyntax', 'TagHighlight'], \ '^\%(c\|cpp\|h\)$': [ 'clang_complete' ], \ 'python': [ 'python_pydoc'], \ 'php': ['phpcomplete', 'PDV_-_phpDocumentor_for_Vim'], \ 'gpg': ['gnupg'], \ } call vam#ActivateAddons(ft_addons['always'], {'auto_install': 1}) au FileType * for l in values(filter(copy(ft_addons), string(expand('')).' =~ v:key')) | call vam#ActivateAddons(l, {'force_loading_plugins_now':1}) | endfor " SuperTab option for context aware completion let g:SuperTabDefaultCompletionType = "context" " If you prefer the Omni-Completion tip window to close when a selection is " " made, these lines close it on movement in insert mode or when leaving " " insert mode if has("autocmd") autocmd CursorMovedI * if pumvisible() == 0|pclose|endif autocmd InsertLeave * if pumvisible() == 0|pclose|endif endif let g:clang_complete_copen = 1 let g:clang_complete_auto = 1 let g:clang_user_options='|| exit 0' if has("cscope") set csto=0 set cst set nocsverb " add any database in current directory if filereadable("cscope.out") cs add cscope.out " else add database pointed to by environment elseif $CSCOPE_DB != "" cs add $CSCOPE_DB endif if filereadable("/usr/linux/cscope.out") cs add /usr/linux/cscope.out endif set csverb endif