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 ;)
+set nobackup
+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Theme/Colors
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set wildmenu " turn on wild menu
set ruler " Always show current positions along the bottom
-"set number " turn on line numbers
+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 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 hlsearch " 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]\ [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
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 expandtab " space instead of tabs
+set smarttab "Use the "shiftwidth" setting for inserting <TAB>s instead of the "tabstop" setting, when at the beginning of a line.
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
imap <S-Insert> <S-MiddleMouse>
cmap <S-Insert> <S-MiddleMouse>
+" map <C-k> to clear search
+nmap <silent><C-k> :nohlsearch<CR>
+
" this makes the mouse paste a block of text without formatting it
" (good for code)
map <MouseMiddle> <esc>"*p
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 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()
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" alt-i (normal mode) inserts a single char, and then switches back to normal
map <A-i> i <ESC>r
-map <F10> <ESC>ggVG:call SuperRetab()<left>
+" set F4 to toogle number/nonumber
+map <silent><F4> :set invnumber<CR>
" encypt the file (toggle)
map <F12> ggVGg?
map <F8> :call MySpellLang()<CR>
-map <F7> :TlistOpen<ESC>
+" Map NERDTree show and hide
+map <F2> :NERDTreeToggle<CR>
+imap <F2> <Esc>:NERDTreeToggle<CR>
+" Taglist toggle
+map <F3> :TlistOpen<CR>
+imap <F3> <Esc>:TlistClose<CR>
+
+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 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")
+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 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")
+
+ " 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
+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Useful abbrevs
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
iab xdate <c-r>=strftime("%d/%m/%y %H:%M:%S")<cr>
-" Latex abbrevs
-"iab cha \chapter{}<ESC>i
-"iab sub \subsection{}
-"iab sec \section{}
-"iab ite \item
-"iab enu \begin{enumerate}<CR>\end{enumerate}<ESC>O
-"iab footn \footnote{}
-"iab tabb \begin{tabbing}<CR>\end{tabbing}<ESC>O
-
-"""""""""""""""""""""""""""
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" General configs
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set titlestring=%t%(\ %M%)%(\ (%{expand(\"%:~:h\")})%)%(\ %a%)\ -\ %{v:servername}
if &term == "screen"
set t_ts=^[k
set title
endif
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" Plugin activation
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" vim-addon-manager
"
-fun SetupVAM()
- let addons_base = expand('$HOME') . '/.vim/addons'
- exec 'set runtimepath+='.addons_base.'/vim-addon-manager'
-
- try
-
- " Plugins that should be always enabled
- call vam#ActivateAddons(['surround','checksyntax','snipmate','snipmate-snippets','gnupg','LargeFile','taglist-plus'], {'auto_install' : 0})
-
- catch /.*/
- echoe v:exception
- endtry
-endf
-call SetupVAM()
-
+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 = {
- \ '^\%(R\|r\)$': [ 'Screen_vim__gnu_screentmux', 'Vim-R-plugin' ],
+ \ 'always': ['surround', 'checksyntax', 'LargeFile', 'snipmate', 'snipmate-snippets', 'The_NERD_tree'],
+ \ 'r': [ 'Screen_vim__gnu_screentmux', 'Vim-R-plugin' ],
+ \ '^\%(c\|cpp\|javascript\|python\|php\|html\|xml\|r\|sh\|css\|java\|make\|xslt\|vim\)$': [ 'taglist-plus' ],
+ \ 'python': ['pythoncomplete', 'pydoc', 'python%790'],
+ \ 'gpg': ['gnupg'],
\ }
+call vam#ActivateAddons(ft_addons['always'], {'auto_install': 1})
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
-
-
-
-