User Tools

Site Tools


vimrc

.vimrc

Este .vimrc é um exemplo e tem minhas contribuições e de outras pessoas 1). Baixe e use a vontade. Faça download do código e coloque em seu ~/.vimrc

~/.vimrc
" Configuration file for vim
 
" Normally we use vim-extensions. If you want true vi-compatibility
" remove change the following statements
"set linebreak 
set clipboard=unnamed           "to all operations work with de OS clipboard
set wrap tw=74
set foldmethod=manual           "turn vim to fast; [foldmethod=expr ; foldmethod=manual]
set paste
set nocompatible            	" Use Vim defaults instead of 100% vi compatibility
set backspace=indent,eol,start	" more powerful backspacing
"set backspace=2
set visualbell                  " remove o bip do terminal pisca a tela
"set vb  t_vb=                   " remove o bip do terminal sem piscar a tela
                                " Now we set some defaults for the editor 
set nu		                	" numera linha
set showmode                    " display ¿-- INSERT --¿ when entering insert mode
set autoindent	            	" always set autoindenting on
"set textwidth=0             	" Don't wrap words by default
set nobackup	            	" Don't keep a backup file
set viminfo='20,\"50        	" read/write a .viminfo file, don't store more than
			                    " 50 lines of registers
set history=150	            	" keep 50 lines of command line history
set ruler	                	" show the cursor position all the time
set hls is              		" highlight para textos casados 
set ic		                	" mostra texto casado dinamicamente enquanto digita (ER pg 63)
		                    	" Suffixes that get lower priority when doing tab completion for filenames.
		                    	" These are files we are not likely to want to edit or read.
set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc
set bk                          "faz um backup do arquivo antes de gravar
"set ffs                         "file format: detecta automaticamente o tipo de arquivo (dos, unix , etc)
 
 
" 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 <Esc>:let current_reg = @"<CR>gvdi<C-R>=current_reg<CR><Esc>
 
" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
 
syntax on                       "ativa o highligt
 
" Debian uses compressed helpfiles. We must inform vim that the main
" helpfiles is compressed. Other helpfiles are stated in the tags-file.
"set helpfile=$VIMRUNTIME/doc/help.txt.gz
 
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
" colorscheme " metacosm " my theme
endif " has ("autocmd")
 
" Some Debian-specific things
augroup filetype
  au BufRead reportbug.*		set ft=mail
  au BufRead reportbug-*		set ft=mail
augroup END
 
" The following are commented out as they cause vim to behave a lot
" different from regular vi. They are highly recommended though.
set showcmd		" Show (partial) command in status line.
set showmatch		" Show matching brackets.
set ignorecase		" Do case insensitive matching
set incsearch		" Incremental search
"set autowrite		" Automatically save before commands like :next and :make
 
" inserido do aurelio
"
"                           .vimrc do aurelio
"                       ------------------------- 
"                   Copie, altere, arrume, use, venda
"                 -------------------------------------
"               http://aurelio.net/doc/dotfiles/vimrc.txt
"             ---------------------------------------------
"...............................................................PSEUDO-FUNCOES
" Exemplo de mapeamentos para serem usados por outros mapeamentos,
" para evitar repeticao de codigo, como seu email ou a data atual.
" O caractere '¤' é apenas um prefixo original para não confundir com texto.
" Para ler variaveis de ambiente faca: imap ¤E <esc>:r! echo $VAR<cr>kJA
imap ¤D  francisco (a) silva.eti.br
imap ¤H  http://www.silva.eti.br
imap ¤D  <esc>:r!date '+\%Y\%m\%d'<cr>
 
 
".........................................................................INFO
" Guarda posicao do cursor e historico da linha de comando :
set viminfo='10,\"30,:40,%,n~/.viminfo
au BufReadPost * if line("'\"")|execute("normal `\"")|endif
 
"......................................................................LIMPEZA
" MostraTab: mostra TAB no inicio e espacos no fim das linhas
map ,mt /^\t\+\\|\s\+$<cr>
" PalavrasRepetidas: procura palavras repetidas no texto
map ,pr /\<\(\w*\) \1\><cr>
" JustificaEmail: justifica os textos de email com o justificador em sed
vmap ,je :!justify.sed<cr>
" MinusculasMaiusculas: converte a primeira letra de cada frase p/MAIUSCULAS
map ,mm :set noic<cr>
       \:%s/\(\(\([.!?]\s*\\|^\s*\)\n^\\|[.?!-] \)\s*"\?\s*\)\([a-zàáéóú]\)/\1\U\4/cg<cr>
 
" O mapeamento acima ',mm' serve para "Maiusculizar" frase escritas
" sem as inicias em maiusculas (eu gosto disso). Ao fazer um
" documento grande, eu normalmente escrevo tudo em minusculas, sem
" me preocupar com os comecos de frase. Depois, basta usar este
" mapeamento e converter tudo de uma vez. A ER esta bem abrangente
" e casa todos os pontos marcados com 'zzz' no texto abaixo:
"
" zzz paragrafo que continua
" em outra linha.
"
" zzz outro paragrafo. zzz segunda frase.
" zzz terceira! zzz mais uma? zzz e outra.
"
" - zzz item de lista
"
" 	zzz frase com um TAB na frente.
"   zzz e uma outra com espacos.
" "zzz que tal uma citacao?"
 
"......................................................DICIONARIO & ORTOGRAFIA
" Dicionario para procurar o auto-complemento de palavras
"set dictionary=/home/verde/.ispell_br
" Completa uma palavra
imap <F7> <c-n>
" Da a sequencia a essa palavra
imap <F8> <c-x><c-n>
" Procura no dicionario
imap <c-d> <c-x><c-k>
" Passa um spell no arquivo
map <F6> :!spell %<cr>
" Usando o ispell (ademar)
"map <F6> :!ispell -b %^M ^M^M :e ^M :new %.bak ^M <F4> gg
" Ispell no modo visual (miura)
":vmap <F12> <ESC>:w! $HOME/spell.tmp <ESC>:new <ESC>^W15-<ESC>:r !spell $HOME/spell.tmp <ESC>^Wji<ESC>^Wr
 
 
 
"................................................................SHELL-SCRIPTS
" Cabecalho padrao para Shell-Scripts, exemplo:
"   #!/bin/sh
"   # meu-script.sh
"   # 19970117 <verde (a) aurelio net>
map <F9>  ggO#!/bin/sh
          \<c-o>:r!echo %<cr># <c-o>o
          \# ¤D Francisco Aparecido da Silva<cr>
" Registro de alteracao (ChangeLog): # 19991213 
map <F10> gg/^$<cr>i# ¤D 
 
" BashTemp: linha de criacao do arquivo temporario com o mktemp
map ,bt IA_TMP=`mktemp /tmp/$(basename $0).XXXXXX`<cr>rm -f $A_TMP<cr>
" BashUso: linha da chamada da funcao Uso()
map ,bu IUso(){ echo "uso: $0 param" ; exit 1 ; }<cr>[ "$1" ] \|\| Uso<cr>
 
 
"......................................................................ARQUIVO
" Sai fora na marra!
imap <F12> <esc>:wqa!<cr>
 map <F12> :wqa!<cr>
" Abreviacoes uteis para sua sanidade mental
cab W w | cab Q q | cab Wq wq | cab wQ wq | cab WQ wq
 
" Gravar selecao visual num arquivo ($TMP eh var de ambiente)
" 1. Usando buffer novo
vmap <F5> y:new<cr>p:w!$TMP/vim<cr>:bd!<cr>
" 2. Colando no fim do arquivo e tirando
"vmap <F5> yGo<esc>p:.,$w!$TMP/vim<cr>u``
 
 
".......................................................................OUTROS
" Alterna entre janelas sem sair do modo insercao (depois do :split)
imap <F4> <esc><c-w><c-w>i
" DiffApaga: apagar uma entrada num arquivao DIFF
"map ,di :.,/diff -[uNr]/-d<cr>
" HtmlSyntaxe: carregar uma sintaxe HTML alternativa 
"map ,hs :so ~/.vim/synload.vim<cr>:so ~/.vim/html.vim<cr>
" HtmlData: atualiza data no fim do arquivo HTML
map ,hd G:?^$<cr>O<pre><cr>--<cr>
       \¤D ¤U<esc>:r!echo ${PWD\#*/html}/%<cr>kJxo</pre>
" Para 'ocultar' e voltar os comentarios do arquivo atual
noremap <F2> :hi Comment ctermfg=black guifg=black<cr>
noremap <F3> :hi Comment term=bold ctermfg=cyan guifg=cyan<cr>
" Busca colorida em verde
hi    Search ctermbg=green ctermfg=black
hi IncSearch ctermbg=black ctermfg=cyan
 
"................................................................OPCOES DO SET
"(IncrementedSearch, HighLightedSearch, IgnoreCase, SmartCaSe)
set is hls ic scs magic   "opcoes espertas de busca
set sm             "ShowMatch: mostra o par do parenteses/chaves recem fechado
set hid            "HIDden: nao lembro pra que servia mas era massa
set aw             "AutoWrite: gravacao automatica a cada alteracao
set ai             "AutoIndent: identacao automatica
set ts=4           "TabStop: numero de caracteres de avanco do TAB
set report=0       "reporta acoes com linhas
set shm=filmnrwxt  "SHortMessages: encurta as mensagem do rodape
"set et             "ExpandTab: troca TABs por espacos
"retab              "converter os TABs ja existentes
set showcmd        "mostra o comando sendo executado
set laststatus=2   "mostra N linhas de estado (status)
set textwidth=70   "quebra de linha
set bs=0           "comportamento do backspace
" set nosmartindent "desligando pois esta padrao no CL40
set smarttab        "use tabs at the start of a line, spaces elsewhere
set visualbell     "pisca a tela ao inves de bipar
"set wrap           "forca a quebra de linha
set nojoinspaces   "! coloca 2 espacos apos o . quando usando o gq
set sw=1           "numero de colunas para o comando > (ShiftWidth)
set wildmode=longest,list:full  "para completacao do TAB igual bash
 
 
"........................................................................CORES
" Cores no terminal com a sintaxe
set background=dark     "eh importante o bg estar ANTES do terminfo
" Acho que essa tosquice toda nao eh mais necessaria
"if has("terminfo")
"  set t_Co=8
"  set t_Sf=[3%p1%dm
"  set t_Sb=[4%p1%dm
"else
"  set t_Co=8
"  set t_Sf=[3%dm
"  set t_Sb=[4%dm
"endif
syntax on               "ligando a sintaxe colorida
 
 
".........................................................COMANDOS AUTOMATICOS
 
" Arquivos .sh sao sempre bash, e não sh
au FileType sh let b:is_bash=1
 
" Palavras-chave para destacar em qualquer tipo de arquivo
syn case ignore
syn keyword p_c francisco silva aparecido 
syn keyword p_c Debian debian
syn keyword p_c linux
syn keyword p_c software livre
syn keyword p_c vi vim emacs sed ed pine bash python
hi p_c ctermbg=white ctermfg=black
 
" Mail: Configuracoes especiais para arquivos de email
au FileType Mail set fo=ctq tw=65 et
 
" Man: Paginas de manual sao na verdade textos em NROFF 
au BufNewFile,BufRead *.man set ft=nroff
 
" TXT: Arquivos texto tem tratamento especial
au BufNewFile,BufRead *.txt   set tw=75 ts=8
au BufNewFile,BufRead *.txt   source ~/.vim/txt.vim
au BufNewFile,BufRead *README source ~/.vim/txt.vim
au BufNewFile,BufRead *NEWS   source ~/.vim/txt.vim
 
" Python: TAB colorido e outras configuracoes
au FileType python set ts=4 tw=80 noet
au FileType python syn match pythonTAB '\t\+'
au FileType python hi pythonTAB ctermbg=blue
au FileType python hi pythonString ctermfg=lightgreen
au FileType python hi pythonRawString ctermfg=lightgreen
 
" Makefile: ele adora usar linhas compridas malas
au BufNewFile,BufRead Makefile set tw=0
 
" Mgp: mudando algumas cores na sintaxe do MagicPoint
au FileType mgp hi mgpFile ctermfg=darkcyan
au FileType mgp hi mgpCommand ctermfg=yellow
 
" Spec: usar o meu arquivo e não o default
au! Syntax spec
au  Syntax spec so ~/www/doc/vim/spec.vim
au BufNewFile,BufRead *.spec set tw=75 et 
 
" Php: Para usar o meu arquivo de sintaxe do php3
"au! Syntax php3
"au  Syntax php3 so ~/www/doc/vim/php3.vim
"au BufNewFile,BufRead *.php   source ~/www/doc/vim/php3.vim 
"au BufNewFile,BufRead *.php3  source ~/www/doc/vim/php3.vim 
 
" HTML: Funcoes particulares para editar arquivos HTML
"au BufNewFile,BufRead *.html,*.shtml so ~/.vimrc-html
" Cria um esqueleto de arquivo HTML ao abrir um arquivo novo .html
"au BufNewFile *.html read ~/www/doc/vim/skel.html
 
" Src: Define arquivos .src como tipo HTML
"au BufNewFile,BufRead *.src set ft=html
 
" Quizz: Sintaxe para meus arquivos de dados do programa quiZZ
au BufNewFile,BufRead *.qzz  so ~/cnc/vim/qzz.vim
 
" Sgml E DocBook: maaaaaaaalas
au BufNewFile,BufRead *.mod set ft=dtd
au BufNewFile,BufRead *.cat set ft=dtd
au BufNewFile,BufRead *.gml set ft=dtd
 
" Netscape: o arquivo de mensagens parece com o xdefaults
au BufNewFile,BufRead Netscape.* set ft=xdefaults
 
" Coluna Do Aurelio: quebrar sempre em 72 colunas
au BufNewFile,BufRead coluna??.txt set tw=72
 
" PageMaker: colorir as marcações
au BufNewFile,BufRead *.pm6 so ~/www/doc/vim/pagemaker.vim 
 
 
".................................................................LIGA/DESLIGA
" (e mostra o valor atual na linha de comando)
" Tem que fazer toda a sequencia sem pausa, senao entra no modo de insercao
" ,: comeco de mapeamento | s: comando :set | [a-z]: sigla da opcao do set
"map ,si :set ai!<cr>:echo "autoIndent="&ai<cr>
"map ,sc :set ic!<cr>:echo "ignoreCase="&ic<cr>
"map ,sc :set ic! ic?<cr>
 
".....................................................................POTFILES
" Copia texto em ingles para a area da traducao
imap <F10> <esc>?^$<cr>/msgid<cr>f"ly$j0f"pxF"a
" Preenche o cabecalho padrao dos POs da FSF
map <F11> :2,3s/YEAR/1999/e<cr>
         \:3s/FIRST AUTHOR/#MEU-NOME#/e<cr>
         \:3s/EMAIL@ADDRESS/#MEU-EMAIL#/e<cr>
         \/^"PO-Revision-Date:<cr>
         \f D:r!date '+\%Y-\%m-\%d \%H:\%M-0300\n"'<cr>kJ
         \/^"Last-Translator:<cr>f Da #MEU-NOME# <#MEU-EMAIL#>\n"<esc>
         \/^"Language-Team:<cr>
         \/^"Content-Type:<cr>f=Da=iso-8859-1\n"<esc>
         \/^"Content-Transfer-Encoding:<cr>f Da 8BIT\n"<esc>
         \:1,15s/#MEU-NOME#/Francisco Aparecido da Silva/<cr>
         \:1,15s/#MEU-EMAIL#/francisco (a) silva eti br /<cr>
 
".....................................................................EXEMPLOS
" DIFF do proprio arquivo editado
"w! diff -u - %
 
" Para usar um arquivo proprio de sintaxe (estraga as outras sintaxes - palha)
":let mysyntaxfile = "/home/verde/vim/dic.vim"
" Ou ainda, especificar um diretorio
"map ,SO :so ~/vim/syntax/
 
" Exemplo de como carregar um arquivo que esta no mesmo diretorio
"au BufNewFile,BufRead */summaries/*    source <sfile>:p:h/tsdsumm.vim
 
" Funciona esse troco?? sei la, preguica de testar...
"let highlight_sedtabs = 1
 
 
".........................................................................MISC
" Mostra os espaços em branco inúteis no final da linha
syn match brancomala '\s\+$' | hi brancomala ctermbg=red
" Esconder as tags HTML (pintando de preto)
map ,hh :syn match preto '<.\{-}>' <cr>:hi preto ctermfg=black ctermbg=blue<cr>
 
" Vim syntax file
" Filename: txt.vim
" Language: plain text :)
" Maintainer: Aurelio Marinho Jargas
" URL: http://aurelio.net/doc/vim/txt.vim
" Instalacao: Colocar no final do seu ~/.vimrc:
"   au BufNewFile,BufRead *.txt source ~/rota/para/txt.vim
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
syn clear
syn case ignore
 
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"MISC:
syn keyword txtTodo    TODO FIXME XXX contained
syn match   txtComment '^#.*$' contains=txtTodo
syn match   txtNumber  '\<\d\+\([,.]\d\+\)\{,1}\>'
syn match   txtPercent '\<\d\+\([,.]\d\+\)\{,1}%'
syn match   txtBlank   '\s\+$'
syn match   txtBar     '^\s*[_=-]\{20,}\s*$'
syn match   txtSpecial '[][(){}®]'
syn match   txtSpecial '\<\(US\|R\)\$'
 
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"URL EMAIL:
syn match txtEmail '\<[A-Za-z0-9_.-]\+@\([A-Za-z0-9_-]\+\.\)\+[A-Za-z]\{2,4}\>\(?[A-Za-z0-9%&=+.,@*_-]\+\)\='
syn match txtUrl   '\<\(\(https\=\|ftp\|news\|telnet\|gopher\|wais\)://\([A-Za-z0-9._-]\+\(:[^ @]*\)\=@\)\=\|\(www[23]\=\.\|ftp\.\)\)[A-Za-z0-9%._/~:,=$@-]\+\>/*\(?[A-Za-z0-9/%&=+.,@*_-]\+\)\=\(#[A-Za-z0-9%._-]\+\)\='
syn match txtEmailMsg '^\s*\(From\|De\|To\|Para\|Date\|Data\|Assunto\|Subject\):.*'
syn match txtEmailQuote '^\(>\($\| \)\)\+'
 
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"LIST:
syn match txtList    '^ *[-+*.] [^ ]'me=e-1
syn match txtList    '^ *[0-9]\+) '
syn match txtDefList '^ *[^:]\{6,\}:'hs=e contains=ALL
 
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"FONT BEAUTIFIERS:
syn match   txtUnderline  '_[^_[:blank:]].\{-}_'hs=s+1,he=e-1
syn match   txtBold       '\*[^*[:blank:]].\{-}\*'hs=s+1,he=e-1
syn match   txtMonospace  "`[^`]\+`"hs=s+1,he=e-1
" max: two lines
syn match   txtParentesis "([^)]\+\(\n\)\=[^)]*)" contains=txtUrl,txtEmail
syn match   txtQuotes     '"[^"]\+\(\n\)\=[^"]*"'hs=s+1,he=e-1
" max: two words
syn match   txtQuotes     "'\w\+ \?\w\+'"hs=s+1,he=e-1
 
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" color definitions (specific)
hi txtBar         term=bold        cterm=bold        gui=bold
hi txtBold        term=bold        cterm=bold        gui=bold
hi txtItalic      term=italic      cterm=italic      gui=italic
hi txtUnderline   term=underline   cterm=underline   gui=underline
"
" color definitions (using Vim defaults)
hi link txtComment      Comment
hi link txtQuotes       String
hi link txtBlank        Error
hi link txtNumber       Number
hi link txtPercent      Number
hi link txtTodo         Todo
hi link txtEmail        PreProc
hi link txtUrl          PreProc
hi link txtList         Statement
hi link txtDefList      Statement
hi link txtMonospace    Special
hi link txtSpecial      Statement
hi link txtParentesis   Comment
hi link txtEmailMsg     Structure
hi link txtEmailQuote   Structure
"
let b:current_syntax = 'txt'
" vim:tw=0:et
"usando o vim para ediçao de blog
 if !exists('*Wordpress_vim')
       runtime vimlog.vim
       endif
"
"
set ls=2
" set laststatus=2
" " Isto faz exibir uma "linha de status" na parte inferior da tela.
"
"
set sc
"" set showcmd
" Quando no modo visual (modo de seleção de caracteres/linhas),
" mostra, no
" canto inferior direito, a quantidade de caracteres/linhas
" selecionados.
set mouse=a
" Liga o suporte a mouse. Isto só é útil quando rodar o Vim dentro de
" um
" terminal (ou seja, rodar "vim" em vez de "gvim"), e mesmo assim às
" vezes
" pode não ser muito útil. Ligue apenas se quiser. Para desligar,
" use
"    :set mouse=
set bg=dark
" set background=dark
" Diz para o Vim que o seu terminal ou a sua janela possui um fundo
" escuro.
" Desta forma, o Vim vai tentar usar cores mais claras para o texto,
" de modo a
"  aumentar a legibilidade. O oposto disto é :set bg=light
"
hi Normal guibg=black guifg=white
" highlight Normal guibg=black guifg=white
" Diz para o Vim usar a cor de fundo preta e a cor de texto branca,
" quando no
" modo gráfico (gvim).
" 
" Inicio Vim Jusfier
" Just another justifier
" Version:    0.3
" Maintainer: Kontra, Gergely <[email protected]>
" GetLatestVimScripts: 177 2 :AutoInstall: MyJustify.vim
" Improved by Charles E. Campbell, Jr.
" Multibyte patch suggested by Teemu Likonen
fun! <SID>Justify(...) range
  if a:0|let tw=&tw|let &tw=a:1|endif
  exe a:firstline
  exe 'norm! V'.a:lastline.'Ggq'
  let lastline=line('.')
  let s=@/|exe 'silent '.a:firstline.','.lastline.'s/\s\+/ /ge'|let @/=s
  let i=a:firstline
  while i<=lastline "NOT a:lastline!!!
    exe i
    let i=i+1
    if getline('.') !~ '\w\s'
      continue
    endif
    while strlen(substitute(getline('.'),'.','x','g'))<&tw
      silent! norm! E
      if strpart(getline('.'),col('.'))=~'^\s*$'
        norm! ^E
      endif
      exe "norm! a \<Esc>"
    endw
  endw
  if a:0
    let &tw=tw
  endif
endfun
com! -nargs=? -range Justify <line1>,<line2>call <SID>Justify(<args>)
" 1,20 Justify --> justifica da linha 1 até a linha 20
" Fim Justify
"
 
"insere numeração de linhas - função < ,n > 
map ,n <esc>:let i=1 <bar> g/^/s//\=i."\t"/ <bar> let i=i+1<cr>

Dúvidas ou sugestões, comente abaixo:

1)
Usei exemplos do Aurélio em http://aurelio.net/doc/dotfiles/vimrc.txt

Discussion

Enter your comment. Wiki syntax is allowed:
 
vimrc.txt · Last modified: 2016/07/12 08:59 by admin