This is Gentoo's testing wiki. It is a non-operational environment and its textual content is outdated.
Please visit our production wiki at https://wiki.gentoo.org
Vim
Vim (Vi IMproved) é um editor de textos baseado no vi. Ele pode ser usado através da interface de linha de comando ou como uma aplicação com interface gráfica.
Instalação
USE flags
USE flags for app-editors/vim Vim, an improved vi-style text editor
X
|
Link console vim against X11 libraries to enable title and clipboard features in xterm |
acl
|
Add support for Access Control Lists |
crypt
|
Use dev-libs/libsodium for crypto support |
cscope
|
Enable cscope interface |
debug
|
Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Backtraces |
gpm
|
Add support for sys-libs/gpm (Console-based mouse driver) |
lua
|
Enable Lua scripting support |
minimal
|
Install a very minimal build (disables, for example, plugins, fonts, most drivers, non-critical features) |
nls
|
Add Native Language Support (using gettext - GNU locale utilities) |
perl
|
Add optional support/bindings for the Perl language |
python
|
Add optional support/bindings for the Python language |
racket
|
Enable support for Scheme using dev-scheme/racket |
ruby
|
Add support/bindings for the Ruby language |
selinux
|
!!internal use only!! Security Enhanced Linux support, this must be set by the selinux profile or breakage will occur |
sound
|
Enable sound support |
tcl
|
Add support the Tcl language |
terminal
|
Enable terminal emulation support |
vim-pager
|
Install vimpager and vimmanpager links |
Emerge
Se não for necessário o suporte ao X Window System, basta instalar o pacote app-editors/vim:
root #
emerge --ask app-editors/vim
Softwares Adicionais
Gvim
Para instalar o Vim tanto com a interface baseada em ncurses (/usr/bin/vim) como a interface gráfica (para o X Window System - /usr/bin/gvim), instale o pacote app-editors/gvim:
root #
emerge --ask app-editors/gvim
Vim-qt
Existe também uma interface experimental Qt chamada app-editors/vim-qt que pode também ser instalada.
Plugins
A categoria "app-vim" fornece uma boa quantidade de definições de sintaxe adicionais, plugins e outros conteúdos relacionados ao Vim.
Use emerge ou eix para obter uma visão geral dos pacotes disponíveis na categoria "app-vim":
user $
emerge --search "%@^app-vim"
user $
eix -cC app-vim
Configuração
Arquivos
O Vim pode ser configurado para cada usuário ou através de um arquivo de configuração global, efetivo para todo o sistema:
- /etc/vim/vimrc - O arquivo global de configurações.
- ~/.vimrc - O arquivo de configuração local, específico para cada usuário. O til (~) significa que este arquivo está localizado na pasta do usuário.
Uso
Primeiros passos
O Vim tem um tutorial que deve durar cerca de 30 minutos do começo ao fim. Inicie-o usando o comando vimtutor:
user $
vimtutor
Color schemes
About a dozen color schemes are shipped with the base Vim package. They can be listed in last line mode by typing colorscheme, then pressing either Ctrl+d or pressing the Tab key twice:
:
colorscheme
blue darkblue default delek desert elflord evening industry koehler morning murphy pablo peachpuff ron shine slate torte zellner
They can be changed in Vim by using the colorscheme (alternatively use colo) command while in last line mode:
:
colorscheme peachpuff
Color schemes can be permanently applied in the .vimrc file:
~/.vimrc
colorscheme peachpuff syntax on
The first line sets the default color scheme while the last line activates the color scheme.
Dicas e truques
Usando Vim como ex ou ed na linha de commando
É possível usar o Vim para one-liners - comandos que podem ser usados em scripts ou na linha de comando para realizar modificações numa maneira não vigiada.
Por exxemplo, o comando a seguir adiciona #
ao começo de cada linha no arquivo file.txt:
user $
vim -c ":%s/^/#/g" -c ":x" file.txt
O que acontece é que o Vim interpreta o que foi passado como comando (através da opção -c
). O primeiro comando é o comando de substituição do Vim (que é bem parecido ao do sed), o segundo é a instrução do Vim para salvar e sair do editor.
Alterar a codificação do arquivo
Para alterar a codificação de um arquivo para UTF-8. use o seguinte comando (no modo de comando do Vim):
:
e ++enc=utf8
Como mostrado na dica anterior, é possível fazer isto diretamente da linha de comando:
user $
vim -c ":wq! ++enc=utf8" file.txt
Veja também
- Guia do Vim - Explica como usar o Vim em maiores detalhes.
Recursos externos
- Vim Documentation Includes Manuals (aka ":help" and Free VIM OPL Book), FAQS, HOWTO's, Tutorials, in HTML PDF, and PS formats.
- A vim Tutorial and Primer - An excellent vim tutorial/primer. Read this first.
- VIM Scripts/Plugins
- Vim for Humans (free ebook) - Clone and cd into the sources directory, mkdir dist, change
sphinx2-build
tosphinx-build
for SPHINXBUILD in rst/en/Makefile. Run ./makedist.sh. Read PDF in ./dist/vimpourleshumains/. - Learning the vi and Vim Editors, 7th Edition O'Reilly Print ISBN: 978-0-596-52983-3, Ebook ISBN: 978-0-596-15935-1
- Vim anti-patterns - A blog entry on maintaining flow with Vim.