vim (vimrc)

Para programadores

Categoria: Vim

Software: vim

[ Hits: 11.278 ]

Por: Charles Jonh Camello


A algum tempo me mandaram este arquivo de conf. e deixa o vi muito bom de trabalhar e gostaria de conpartilhar com todos, para que funcione mova o arquivo vimrc para o ~/.vimrc e bom trabalho


set nocompatible   " Use Vim defaults (much better!)
set bs=2      " allow backspacing over everything in insert mode
set autoindent      " always set autoindenting on
set ts=4
set sw=4
set smartindent   " always set smartindenting on
" set backup      " keep a backup file
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 textwidth=0      " Don't wrap words by default
set ruler      " Show the line and column numbers of the cursor 

" 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

" Don't use Ex mode, use Q for formatting
map Q gq

" 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>

" Delete key
:if &term =~ "xterm"
  set t_kD=[3~
:endif


" And colors
:if &term =~ "xterm" || &term =~ "linux"
  set background=dark
  set t_Co=8
  set t_Sf=[3%dm
  set t_Sb=[4%dm
:endif

" gvim
:if has("gui_running")
  set background=light
  set t_Co=16
:endif

" if you like highlight search, you can also reconfigure the colors
":hi search guifg=black
":set background=light
":hi ErrorMsg guifg=black
":set bg=dark

" nice syntax
if has("syntax") && filereadable($VIMRUNTIME . "/syntax/syntax.vim") && (&t_Co > 2 || has("gui_running"))
  syntax on
endif

" Only do this part when compiled with support for autocommands.
if has("autocmd")

 " C programing
 augroup cprog
  " Remove all cprog autocommands
  au!

  " When starting to edit a file:
  "   For C and C++ files set formatting of comments and set C-indenting on.
  "   For other files switch it off.
  "   Don't change the order, it's important that the line with * comes first.
  autocmd FileType *      set formatoptions=tcql nocindent comments&
  autocmd FileType c,cpp  set formatoptions=croql cindent comments=sr:/*,mb:*,el:*/,://
 augroup END

 " edit gziped files
 augroup gzip
  " Remove all gzip autocommands
  au!

  " Enable editing of gzipped files
  " set binary mode before reading the file
  autocmd BufReadPre,FileReadPre   *.gz,*.bz2 set bin
  autocmd BufReadPost,FileReadPost   *.gz call GZIP_read("gunzip")
  autocmd BufReadPost,FileReadPost   *.bz2 call GZIP_read("bunzip2")
  autocmd BufWritePost,FileWritePost   *.gz call GZIP_write("gzip")
  autocmd BufWritePost,FileWritePost   *.bz2 call GZIP_write("bzip2")
  autocmd FileAppendPre         *.gz call GZIP_appre("gunzip")
  autocmd FileAppendPre         *.bz2 call GZIP_appre("bunzip2")
  autocmd FileAppendPost      *.gz call GZIP_write("gzip")
  autocmd FileAppendPost      *.bz2 call GZIP_write("bzip2")

  " After reading compressed file: Uncompress text in buffer with "cmd"
  fun! GZIP_read(cmd)
    let ch_save = &ch
    set ch=2
    execute "'[,']!" . a:cmd
    set nobin
    let &ch = ch_save
    execute ":doautocmd BufReadPost " . expand("%:r")
  endfun

  " After writing compressed file: Compress written file with "cmd"
  fun! GZIP_write(cmd)
    if rename(expand("<afile>"), expand("<afile>:r")) == 0
      execute "!" . a:cmd . " <afile>:r"
    endif
  endfun

  " Before appending to compressed file: Uncompress file with "cmd"
  fun! GZIP_appre(cmd)
    execute "!" . a:cmd . " <afile>"
    call rename(expand("<afile>:r"), expand("<afile>"))
  endfun

 augroup END

endif " has("autocmd")

" Several maps useful for most terminals
map  <Up>
map!  <Up>
map  <Down>
map!  <Down>
map  <Left>
map!  <Left>
map  <Right>
map!  <Right>
map  <Home>
map!  <Home>
map OH <Home>
map! OH <Home>
map  <End>
map!  <End>
map OF <End>
map! OF <End>
map [3~ <Delete>
map! [3~ <Delete>

" 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 & :make
  


Comentários
[1] Comentário enviado por diegotosco em 27/12/2006 - 22:18h

Caramba muito legal. Tentei vários .vimrc's daqui do VOL e todos deram o mesmo problema: "Not an editor command: ^M"

O teu funcionou certinho!

Valeu

[2] Comentário enviado por napalm em 19/03/2007 - 13:37h

Boas
aqui está a dar erro...
é suposto meter o ficheiro em /etc/vim/vimrc, certo?

sao estes os erros:
Error detected while processing /usr/share/vim/vimrc:
line 1:
E492: Not an editor command: ^M
line 5:
E474: Invalid argument: ts=4^M
line 6:
E474: Invalid argument: sw=4^M
line 12:
E492: Not an editor command: ^M
line 15:
E492: Not an editor command: ^M
line 19:
E492: Not an editor command: ^M
line 22:
E492: Not an editor command: ^M
line 25:
E492: Not an editor command: ^M
line 27:
E15: Invalid expression: &term =~ "xterm"^M
line 144:
E171: Missing :endif

[3] Comentário enviado por xshadow em 03/05/2007 - 12:38h

Pô legal mesmo, nao funcionou também, gostaria que se puder mandar a correção também... obrigado!

[4] Comentário enviado por rbarivi em 29/08/2007 - 10:05h

esses problemas com o ^M podem ser resolvidos com o comando
dos2unix .vimrc

dos2unix pertence ao pacote tofrodos


Contribuir com comentário

  



Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts