""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " 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 " real man don't use backups ;) """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Theme/Colors """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" syntax on " syntax highlighting on set background=dark set t_Co=256 colorscheme desert "colorscheme xoria256 "let g:solarized_termcolors=256 "colorscheme solarized """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " 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=2 " make backspace work normal set whichwrap+=<,>,h,l " backspace and cursor keys wrap to set mouse=a " use mouse everywhere 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 " do not highlight searched for phrases set incsearch " BUT 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]\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ [POS=%04l,%04v][%p%%]\ [LEN=%L] 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 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 please! set nowrap " do not wrap lines autocmd FileType c,cpp,slang set cindent autocmd FileType c,cpp,slang set textwidth=79 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Folding " Enable folding, but by default make it act like folding is off, because folding is annoying in anything but a few rare cases """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" set foldenable " Turn on folding set foldmethod=indent " Make folding indent sensitive set foldlevel=100 " Don't autofold anything (but I can still fold manually) set foldopen-=search " don't open folds when you search into them set foldopen-=undo " don't open folds when you undo stuff """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " 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 " 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 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Select range, then hit :SuperRetab($width) - by p0g and FallingCow function! SuperRetab(width) range silent! exe a:firstline . ',' . a:lastline . 's/\v%(^ *)@<= {'. a:width .'}/\t/g' endfunction "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 map ggVG:call SuperRetab() " encypt the file (toggle) map ggVGg? map :call MySpellLang() map :TlistOpen """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Autocommands """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 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") """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Useful abbrevs """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" iab xdate =strftime("%d/%m/%y %H:%M:%S") " Latex abbrevs "iab cha \chapter{}i "iab sub \subsection{} "iab sec \section{} "iab ite \item "iab enu \begin{enumerate}\end{enumerate}O "iab footn \footnote{} "iab tabb \begin{tabbing}\end{tabbing}O """"""""""""""""""""""""""" 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 " vim-addon-manager " fun SetupVAM() let addons_base = expand('$HOME') . '/.vim/addons' exec 'set runtimepath+='.addons_base.'/vim-addon-manager' " unix based os users may want to use this code checking out VAM " if !isdirectory(addons_base.'/vim-addon-manager') " exec '!p='.shellescape(addons_base).'; mkdir -p "$p" && cd "$p" && git clone --depth 1 git://github.com/MarcWeber/vim-addon-manager.git' " endif " commenting try .. endtry because trace is lost if you use it. " There should be no exception anyway try let g:solarized_termcolors=256 call vam#ActivateAddons(['github:altercation/vim-colors-solarized']) call vam#ActivateAddons(['surround','checksyntax','snipmate','snipmate-snippets','gnupg','LargeFile','taglist-plus'], {'auto_install' : 0}) " pluginA could be github:YourName see vam#install#RewriteName() catch /.*/ echoe v:exception endtry endf call SetupVAM() let ft_addons = { \ '^\%(R\|r\)$': [ 'Screen_vim__gnu_screentmux', 'Vim-R-plugin' ], \ } au FileType * for l in values(filter(copy(ft_addons), string(expand('')).' =~ v:key')) | call vam#ActivateAddons(l, {'force_loading_plugins_now':1}) | endfor " experimental: run after gui has been started (gvim) [3] " option1: au VimEnter * call SetupVAM() " option2: au GUIEnter * call SetupVAM() " See BUGS sections below [*]