Desabilitando a autoindentação do VIM

Posted on abr 03, 2009 under Dicas Linux | 2 Comentários

Sempre que começo a escrever algum código com o VIM e necessito colar algo o VIM autoindenta! Inseri tabs ou comentários, então pesquisando na web descobri uma maneira simples de desabilitar a autoindentação:

:set paste

Depois de ter colado o que eu quero, para habilitar novamente a autoindentação basta digitar:

:set nopaste

Existem outras formas, mas essa achei mais fácil de me lembrar é bem intuitiva.

fonte:blog.exeko.com

2 Responses to “Desabilitando a autoindentação do VIM”

  1. Oi Marlon!

    Vou colar aqui o meu vimrc, acho legal compartilhar as macros que eu uso, tornam a vida mais fácil :)

    # cat ~/.vimrc

    ” Basic
    set background=dark
    set undolevels=200
    set scrolloff=3
    set backspace=indent,eol,start
    set formatoptions=
    set nowrap
    set nostartofline
    set nocompatible
    set showcmd
    set ttyfast
    set ruler
    set lazyredraw
    set whichwrap=b,s,h,l,,~,[,]
    set cpoptions=aABceFsmq
    filetype plugin indent on
    filetype plugin on

    ” Backup
    set backup ” keeps file backups
    set backupdir=~/.vim/backup
    set directory=~/.vim/tmp

    ” Code
    set showmatch ” shows matching block delimiters
    set matchtime=5
    set syntax=on ” nice colors when coding
    highlight Vars ctermbg=yellow ctermfg=black
    let m = matchadd(‘Vars’, ‘%\w\+%’) ” matches %VAR% %var% %T_var%
    let m = matchadd(‘Vars’, ‘@\w\+@’) ” matches @VAR@ @var@ @T_var@
    let m = matchadd(‘Vars’, ‘\$\w\+’) ” matches $VAR $var $T_var
    set listchars=tab:>-,trail:- ” shows tabs and trailing spaces and tabs
    set list

    ” Indent
    set autoindent ” indentation is important
    set expandtab ” uses spaces for tab
    set tabstop=4
    set shiftwidth=4

    ” Width
    set textwidth=78 ” try not to be much verbose when coding or writting e-mails
    highlight Overwidth ctermbg=grey ctermfg=red
    let m = matchadd(‘Overwidth’, ‘\%78v.*’) ” if we are passing the limits, warn

    ” Search
    set ignorecase
    set smartcase
    set hlsearch
    set incsearch

    ” Mappings
    map :bp ” previous opened file
    map :bn ” next opened file
    map :set wrap!set wrap? ” wrap on/off
    map :set paste!set paste? ” paste on/off
    map :set number!set number? ” number on/off
    ” rot13
    map ggVGg? ” encode/decode for fun

    ” Defines
    ab ==l —————————————————————————-
    ab ==# ############################################################################
    ” puts date in cvs format
    map ,d :r!date +”\%a \%b \%d \%Y”
    ” dos2unix
    vmap ,du :s/\r//g
    ” remove all trailing spaces and tabs
    vmap ,tt :s/[ ]*$//g
    ” replace all tabs with 4 spaces
    vmap ,ts :s// /g
    ” normalize
    map ggVG,du ” dos2unix entire file
    map ggVG,tt ” remove trailing spaces and tabs for the entire file
    map ggVG,ts ” replace tabs for spaces in the entire file

    ” Status
    set fileformats=unix,dos,mac
    set laststatus=2
    set statusline=%F\ %m%r%h%w\ [syntax:%y\ format:%{&ff}]\ [%l/%L\ (%p%%)\ %l,%c]

    ” Mouse
    “set mouse=a ” use mouse for everything

    ” Save folds
    “au BufWinLeave * mkview
    “au BufWinEnter * silent loadview

    Att,
    Rogério Schneider

  2. admin disse:

    Valeu Rogério.

    Interessante teus macros

Leave a Reply