1 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
   3 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
   4 set nocompatible " get out of horrible vi-compatible mode
 
   5 filetype indent plugin on | syn on
 
   6 set history=1000 " How many lines of history to remember
 
   7 set cf " enable error files and error jumping
 
   8 set ffs=unix,dos,mac " support all three, in this order
 
   9 set viminfo+=! " make sure it can save viminfo
 
  10 set isk+=_,@,- " none of these should be word dividers, so make them not be
 
  13 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
  15 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
  16 syntax on " syntax highlighting on
 
  22 "let g:solarized_termcolors=256
 
  24 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
  26 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
  27 set wildmenu " turn on wild menu
 
  28 set ruler " Always show current positions along the bottom 
 
  29 set number " turn on line numbers
 
  30 set lz " do not redraw while running macros (much faster) (LazyRedraw)
 
  31 set hid " you can change buffer without saving
 
  32 set backspace=2 " make backspace work normal    
 
  33 set whichwrap+=<,>,h,l  " backspace and cursor keys wrap to
 
  34 set shortmess=atI " shortens messages to avoid 'press a key' prompt 
 
  35 set report=0 " tell us when anything is changed via :...
 
  36 " make the splitters between windows be blank
 
  37 set fillchars=vert:\ ,stl:\ ,stlnc:\ 
 
  39 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
  41 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
  42 set showmatch " show matching brackets
 
  43 set mat=5 " how many tenths of a second to blink matching brackets for
 
  44 set hlsearch " highlight searched for phrases
 
  45 set incsearch " do highlight as you type you search phrase
 
  46 set listchars=tab:\|\ ,trail:.,extends:>,precedes:<,eol:$ " what to show when I hit :set list
 
  47 set so=10 " Keep 10 lines (top/bottom) for scope
 
  48 set novisualbell " don't blink
 
  49 set noerrorbells " no noises
 
  50 set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%04l,%04v][%p%%]
 
  51 set laststatus=2 " always show the status line
 
  53 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
  54 " Text Formatting/Layout
 
  55 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
  56 set fo=tcrqn " See Help (complex)
 
  58 set tabstop=4 " tab spacing (settings below are just to unify it)
 
  59 set softtabstop=4 " unify
 
  60 set shiftwidth=4 " unify 
 
  61 set expandtab " space instead of tabs 
 
  62 set smarttab "Use the "shiftwidth" setting for inserting <TAB>s instead of the "tabstop" setting, when at the beginning of a line.
 
  63 set nowrap " do not wrap lines  
 
  65 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
  67 "    Enable folding, but by default make it act like folding is off, because folding is annoying in anything but a few rare cases
 
  68 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
  69 set foldenable " Turn on folding
 
  70 set foldmethod=indent " Make folding indent sensitive
 
  71 set foldlevel=100 " Don't autofold anything (but I can still fold manually)
 
  72 set foldopen-=search " don't open folds when you search into them
 
  73 set foldopen-=undo " don't open folds when you undo stuff
 
  75 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
  77 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
  78 set mouse=a                     " mouse support in all modes
 
  79 set mousehide                   " hide the mouse when typing text
 
  81 " ,p and shift-insert will paste the X buffer, even on the command line
 
  82 nmap <LocalLeader>p i<S-MiddleMouse><ESC>
 
  83 imap <S-Insert> <S-MiddleMouse>
 
  84 cmap <S-Insert> <S-MiddleMouse>
 
  86 " map <C-k> to clear search
 
  87 nmap <silent><C-k> :nohlsearch<CR>
 
  89 " this makes the mouse paste a block of text without formatting it 
 
  91 map <MouseMiddle> <esc>"*p
 
  93 " Convenient for non italian keyboard
 
  96 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
  98 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
  99 let b:match_ignorecase = 1
 
 101 " make tab in v mode ident code
 
 105 " make tab in normal mode ident code
 
 106 nmap <tab> I<tab><esc>
 
 107 nmap <s-tab> ^i<bs><esc>
 
 109 "Easy to access esc key
 
 113 " paste mode - this will avoid unexpected effects when you
 
 114 " cut or copy some text from one window and paste it in Vim.
 
 117 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
 119 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
 120 let perl_extended_vars=1 " highlight advanced perl vars inside strings
 
 122 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
 124 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
 125 "switch spellcheck languages
 
 126 let g:myLangList = [ "none", "it", "en_us" ]
 
 127 function! MySpellLang()
 
 128 "loop through languages
 
 129 if !exists( "b:myLang" )
 
 132 let b:myLang = b:myLang + 1
 
 133 if b:myLang >= len(g:myLangList) | let b:myLang = 0 | endif
 
 135 if b:myLang== 0 | setlocal spell nospell | endif
 
 136 if b:myLang== 1 | setlocal spell spelllang=it | endif
 
 137 if b:myLang== 2 | setlocal spell spelllang=en_us | endif
 
 139 echo "language spell:" g:myLangList[b:myLang]
 
 142 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
 144 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
 145 " alt-i (normal mode) inserts a single char, and then switches back to normal
 
 147 " set F4 to toogle number/nonumber
 
 148 map <silent><F4> :set invnumber<CR>
 
 149 " encypt the file (toggle)
 
 151 map <F8> :call MySpellLang()<CR>
 
 152 " Map NERDTree show and hide
 
 153 map <F2> :NERDTreeToggle<CR>
 
 154 imap <F2> <Esc>:NERDTreeToggle<CR>
 
 156 map <F3> :TlistOpen<CR>
 
 157 imap <F3> <Esc>:TlistClose<CR>
 
 160 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
 162 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
 164     " Enable file type detection ('filetype on').
 
 165     " Syntax of these languages is fussy over tabs Vs spaces
 
 166     autocmd FileType make setlocal ts=8 sts=8 sw=8 noexpandtab
 
 167     autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
 
 168     " Customisations based on house-style (arbitrary)
 
 169     autocmd FileType html setlocal ts=2 sts=2 sw=2 expandtab
 
 170     autocmd FileType css setlocal ts=2 sts=2 sw=2 expandtab
 
 172     autocmd FileType sh setlocal ts=4 sts=4 sw=4 expandtab
 
 173     " Treat .rss files as XML
 
 174     autocmd BufNewFile,BufRead *.rss,*.atom setfiletype xml
 
 176     autocmd FileType c,cpp,slang set cindent
 
 177     autocmd FileType c,cpp,slang set textwidth=79
 
 179     autocmd BufEnter * :syntax sync fromstart " ensure every file does syntax highlighting (full)
 
 180     autocmd BufNewFile *.sh call append(0, "#!/bin/bash")
 
 181     autocmd BufNewFile *.pl call append(0, "#!/usr/bin/perl")
 
 182     autocmd BufNewFile *.py call append(0, "#!/bin/python")
 
 184     " When editing a file, always jump to the last known cursor position.
 
 185     " Don't do it when the position is invalid or when inside an event handler
 
 186     " (happens when dropping a file on gvim).
 
 187     autocmd BufReadPost *
 
 188         \ if line("'\"") > 0 && line("'\"") <= line("$") |
 
 189         \ exe "normal g`\"" |
 
 194 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
 196 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
 197 iab xdate <c-r>=strftime("%d/%m/%y %H:%M:%S")<cr> 
 
 199 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
 201 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
 202 set titlestring=%t%(\ %M%)%(\ (%{expand(\"%:~:h\")})%)%(\ %a%)\ -\ %{v:servername}
 
 207 if &term == "screen" || &term == "xterm"
 
 211 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
 213 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
 216 let vam_install_path = expand('$HOME') . '/.vim/addons'
 
 217 exec 'set runtimepath+='.vam_install_path.'/vim-addon-manager'
 
 218 " Enable addons with vim-addon-manager using file type recognition
 
 220     \ 'always': ['surround', 'checksyntax', 'LargeFile', 'snipmate', 'snipmate-snippets', 'The_NERD_tree'],
 
 221     \ 'r': [ 'Screen_vim__gnu_screentmux', 'Vim-R-plugin' ],
 
 222     \ '^\%(c\|cpp\|javascript\|python\|php\|html\|xml\|r\|sh\|css\|java\|make\|xslt\|vim\)$': [ 'taglist-plus' ],
 
 223     \ 'python': ['pythoncomplete', 'pydoc', 'python%790'],
 
 226 call vam#ActivateAddons(ft_addons['always'], {'auto_install': 1})
 
 227 au FileType * for l in values(filter(copy(ft_addons), string(expand('<amatch>')).' =~ v:key')) | call vam#ActivateAddons(l, {'force_loading_plugins_now':1}) | endfor