pasted by freakcode at 2008-07-05 04:53:58 UTC
URL: http://nopaste.com/p/aMCqZpzUP

repasteplain text

Description: .vimrc


set history=50
set wildmode=list:longest,full
set shortmess+=r

" 256 cores e tema gardener
set t_Co=256
colorscheme gardener

" opções para barra de status e numeração de linhas
set showmode
set showcmd
set number

" opções para largura de texto, tabs, tabs como espaços, etc
set textwidth=79
set bs=2
set tabstop=4
set shiftwidth=4
set expandtab
set softtabstop=4

" tecla F2 para habilitar colagem do X (botão direito do mouse)
set pastetoggle=<F2>

" indentação, colorização de sintaxe, etc
set autoindent
syntax on
filetype on
filetype indent on

" destacar linha atual
set cursorline
hi CursorLine term=standout cterm=standout

" <home> alterna para inicio da linha/inicio do codigo
imap <khome> <home>
nmap <khome> <home>
inoremap <silent> <home> <C-O>:call Home()<CR>
nnoremap <silent> <home> :call Home()<CR>
function Home()
    let curcol = wincol()
    normal ^
    let newcol = wincol()
    if newcol == curcol
        normal 0
    endif
endfunction

" <end> alterna para final da linha/final do código
imap <kend> <end>
nmap <kend> <end>
inoremap <silent> <end> <C-O>:call End()<CR>
nnoremap <silent> <end> :call End()<CR>
function End()
    let curcol = wincol()
    normal g$
    let newcol = wincol()
    if newcol == curcol
        normal $
    endif
    if virtcol(".") == virtcol("$") - 1
        normal $
    endif
endfunction

" comentários em C/C++ e PHP
fu! ComentCPhp()
try
execute 's/^\(\( \|\t\)*\)\/\//\1'
catch
execute 's/\(\( \|\t\)*\)/\1\/\/'
endtry
endfu

" comentários em Python e shell script
fu! ComentPySh()
try
execute 's/^\(\( \|\t\)*\)\#/\1'
catch
execute 's/\(\( \|\t\)*\)/\1\#'
endtry
endfu

" aplicar a função correta de comentários para <Control> + <C> dependendo do tipo de arquivo
autocmd BufRead,BufNewFile *.c,*.cpp,*.h,*.php,*.php*,*.thtml map <C-c> :call ComentCPhp()<cr>

autocmd BufRead,BufNewFile *.py,*.sh map <C-c> :call ComentPySh()<cr>

" sintaxe PHP para arquivos .thtml
autocmd BufRead,BufNewFile *.thtml setfiletype php