omab /.vimrc

" Configuration file for vim

" Prevent modelines in files from being evaluated (avoids a potential
" security problem wherein a malicious user could write a hazardous
" modeline into a file) (override default value of 5)
set modelines=2
set backspace=indent,eol,start	" more powerful backspacing
set nocompatible	    " Use Vim defaults instead of 100% vi compatibility
set number              " Show line numbers
set viminfo='20,\"50	" Read/write a .viminfo file, don't store more than 50 lines of registers
set history=50		    " Keep 50 lines of command line history
set ruler		        " Show the cursor position all the time
set showmode            " Show which mode are we in
set showcmd		        " Show (partial) command in status line.
set hlsearch            " Highlight search matches
set noignorecase	    " Do case sensitive matching
set incsearch		    " Incremental search
set noautowrite		    " Automatically save before commands like :next and :make
set smarttab            "  deletes a tab not only a space
set shiftwidth=4        " Number of space characters inserted for indentation
set expandtab           " Insert space characters whenever the tab key is pressed
set tabstop=4           " Number of space characters that will be inserted when tab is pressed
set smartindent		    " Always set autoindenting on
set autoindent		    " Always set autoindenting on
set showmatch		    " Show matching brackets.
set backupdir=~/tmp,/tmp  " Group backup files on this directories
set directory=.,~/tmp,/tmp  " Group swap files on this directories
set dictionary=~/.vim/wordlists/c.list,~/.vim/wordlists/php.list   "Wordlists for completion
set cpt=.,k,w,d
set background=dark
set encoding=utf-8
set winminheight=0
set winminwidth=0
set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc

" Folding
set foldtext=""         " Don't show fold's first line
set foldmethod=indent
set nofoldenable

syntax on

" We know xterm-debian is a color terminal
if &term =~ "xterm-debian" || &term =~ "xterm-xfree86"
  set t_Co=16
  set t_Sf=[3%dm
  set t_Sb=[4%dm
endif

" Make p in Visual mode replace the selected text with the "" register.
vnoremap p :let current_reg = @"gvdi=current_reg

if has("autocmd")
 " Enabled file type detection
 " Use the default filetype settings. If you also want to load indent files
 " to automatically do language-dependent indenting add 'indent' as well.
 filetype plugin on

endif " has ("autocmd")

" Some Debian-specific things
augroup filetype
  au BufRead reportbug.*		set ft=mail
  au BufRead reportbug-*		set ft=mail
augroup END

" Set paper size from /etc/papersize if available (Debian-specific)
if filereadable('/etc/papersize')
  let s:papersize = matchstr(system('/bin/cat /etc/papersize'), '\p*')
  if strlen(s:papersize)
    let &printoptions = "paper:" . s:papersize
  endif
  unlet! s:papersize
endif


"KEY MAPS"
""""""""""
"------------------------------------------------------------
"Space opens a fold recusively
nmap  zA
"CR as in insert mode (break lines)
nmap  i
"Y yanks to the end of the line as it should be
nmap Y y$
"Tab takes you to the next window:
nmap  _
nmap   W_
nmap  :tabprevious
"' jumps to the precise location of a marks (`)
map ' `
"Apply the commands recorded in q on the vilual selection
vnoremap ` :normal @q
"--------------------------------------------------------------

"Open file same dir--------------------------------------------
"On the current window
map ,e :e =expand("%:p:h") . "/" 
"On a new vertical window
map ,v :vsp =expand("%:p:h") . "/" 
"On a new horizontal window
map ,h :sp =expand("%:p:h") . "/" 
"--------------------------------------------------------------

"Programming utils-------------------------------------------
" comment (#)
nmap sc 0i# 
vmap  sc :s/^/# /:silent noh
" uncomment (#)
nmap su :s/^# //
vmap  su :s/^# //:silent noh
"--------------------------------------------------------------

"Misc----------------------------------------------------------
"Line numbers ON/OFF
map ,n :set number!
"Read and write one block of text between vim sessions
nmap ,r   :r $HOME/.vimxfer
nmap ,w   :'a,.w! $HOME/.vimxfer
vmap ,r   c:r $HOME/.vimxfer
vmap ,w   :w! $HOME/.vimxfer
nmap  ,, :silent noh
"-------------------------------------------------------------

highlight Folded ctermfg=darkmagenta

nmap   :write
imap   :write

function! SuperTab()
    if (strpart(getline('.'),col('.')-2,1)=~'^\s\?$')
        return "\"
    else
        return "\"
    endif
endfunction
imap  =SuperTab()

noremap  :prev
noremap  :n

map  gj
map  gk

map ,st i#include int main(int argc,char **argv){return 0;} 

function! Svndiff2()
    let dir = expand('%:p:h')
    let fn = expand('%')
    execute ":vert diffsplit" . dir . "/.svn/text-base/" . fn . ".svn-base"
    unlet fn dir
    return
endfunction

function! Svndiff()
    let fn = expand('%:p')
    new
    set ft=diff
    execute ":.!svn diff -r BASE " . fn
    unlet fn
    return
endfunction

function! Html_entities()
    execute ':%s/á/\á/g'
    execute ':%s/é/\é/g'
    execute ':%s/í/\í/g'
    execute ':%s/ó/\ó/g'
    execute ':%s/ú/\ú/g'
    execute ':w'
    execute ':next'
    return
endfunction

nmap ## :call Html_entities()
nmap  ,D :call Svndiff()
nmap  ,d :call Svndiff2()

" spell check
nmap ,spes :set spell spelllang=es
nmap ,spen :set spell spelllang=en

" tabs
nmap sn :tabnew
nmap sc :tabclose
nmap sj :tabnext
nmap sh :tabfirst
nmap sk :tabprevious
nmap sl :tablast
nmap st :tabs

" git commit file syntax file
autocmd BufNewFile,BufRead COMMIT_EDITMSG set filetype=gitcommit

colorscheme peachpuff

" highlight de las funciones de la glibc
let c_hi_identifiers = 'all'
let c_hi_libs = ['*'] 

map Y "+y$

" higliht cursor line
hi CursorLine term=none cterm=none ctermbg=0
set cursorline