Chuleta de Vim
NUEVOChuleta de Vim con modos, movimiento, edición, búsqueda y reemplazo, objetos de texto, macros, buffers y cómo guardar y salir (:wq, :q!, ZZ). Con búsqueda y copia en un clic.
Es texto estático: nada de lo que escribes en el filtro sale de tu navegador. Las teclas, los comandos y sus descripciones breves se muestran en inglés.
107 entradas en 11 secciones
Modes
Vim starts in Normal mode. Most keys below are typed in Normal mode unless a section says otherwise.
Esc or Ctrl-[Return to Normal mode from any other mode.
iInsert before the cursor.
aInsert after the cursor (append).
IInsert at the first non-blank character of the line.
AInsert at the end of the line.
oOpen a new line below and start inserting.
OOpen a new line above and start inserting.
vStart Visual mode: select characters.
VStart Visual Line mode: select whole lines.
Ctrl-vStart Visual Block mode: select a rectangle of columns.
RReplace mode: typed characters overwrite existing ones.
:Open the command line (Ex commands such as :w).
Moving around
h j k lMove left, down, up, right.
w / bNext word start / previous word start.
eJump to the end of the word.
0Start of the line.
^First non-blank character of the line.
$End of the line.
ggFirst line of the file.
GLast line of the file.
42GGo to line 42 (:42 does the same).
%Jump to the matching bracket, parenthesis or brace.
{ / }Previous / next blank line (paragraph).
Ctrl-d / Ctrl-uScroll half a page down / up.
fxJump forward to the next "x" on the line; ; repeats, , reverses.
Editing
xDelete the character under the cursor.
rxReplace the character under the cursor with "x".
cwChange from the cursor to the end of the word (deletes it and starts inserting).
ccChange the whole line.
JJoin the next line onto the current line.
>> / <<Indent / unindent the current line.
uUndo.
Ctrl-rRedo.
.Repeat the last change.
Delete, yank (copy), paste
Delete and change commands also store the text, so d then p works as cut and paste.
ddDelete (cut) the current line.
3ddDelete three lines, starting at the current one.
dwDelete from the cursor to the start of the next word.
DDelete from the cursor to the end of the line.
yyYank (copy) the current line.
pPaste after the cursor (or below, for whole lines).
PPaste before the cursor (or above, for whole lines).
ggdGDelete the entire file contents.
"+yYank into the system clipboard (needs a Vim built with +clipboard); "+p pastes from it.
Search & replace
/patternSearch forward for pattern (a regular expression).
?patternSearch backward for pattern.
n / NNext / previous match.
* / #Search forward / backward for the word under the cursor.
:nohClear the search highlighting until the next search.
:s/old/new/gReplace every "old" on the current line (without g, only the first).
:%s/old/new/gReplace every "old" in the whole file.
:%s/old/new/gcReplace in the whole file and confirm each change (y / n / a / q).
:5,12s/old/new/gReplace only on lines 5 to 12.
:g/pattern/dDelete every line that matches the pattern.
Visual mode
Select with v, V or Ctrl-v, then apply an action to the selection.
ggVGSelect the whole file.
gvReselect the previous Visual selection.
> / <Indent / unindent the selected lines.
:'<,'>Pressing : in Visual mode fills this range in for you, so a command runs on the selected lines only.
Ctrl-v j j I# EscBlock insert: add "#" at the start of the selected lines (comment them out).
Ctrl-v j j $A; EscBlock append: add ";" at the end of every selected line.
Text objects
Use after an operator such as d, c, y or v: "i" means inside, "a" means around (including delimiters).
diwDelete the word under the cursor.
dawDelete the word and the space after it.
ci"Change the text inside double quotes.
ci(Change the text inside parentheses (cib is the same).
di{Delete everything inside curly braces.
citChange the content inside an HTML/XML tag.
dapDelete a paragraph including its trailing blank line.
Registers, marks & macros
"ayyYank the line into register a.
"apPaste from register a.
:regList the contents of all registers.
maSet mark a at the cursor position.
'aJump to the start of the line with mark a.
`aJump to the exact position of mark a.
Ctrl-o / Ctrl-iJump back / forward through the jump list.
qaStart recording a macro into register a.
qStop recording (when a recording is active).
@aPlay macro a.
@@Repeat the last played macro.
Windows, tabs & buffers
:split or :spSplit the window horizontally.
:vsplit or :vsSplit the window vertically.
Ctrl-w h/j/k/lMove to the window on the left / below / above / right.
Ctrl-w oClose every window except the current one.
:tabnew fileOpen a file in a new tab page.
gt / gTGo to the next / previous tab.
:lsList open buffers.
:bnext / :bprevSwitch to the next / previous buffer.
:b 3Switch to buffer number 3.
Files & quitting
:wSave the file.
:qQuit (fails if there are unsaved changes).
:q!Quit and discard unsaved changes.
:wqSave and quit.
:xSave only if there are changes, then quit.
ZZSame as :x, typed in Normal mode.
ZQSame as :q!, typed in Normal mode.
:qa!Quit every window and discard all unsaved changes.
:e file.txtOpen another file.
:e!Reload the file from disk and discard unsaved changes.
:w !sudo tee % > /dev/nullSave a file you opened without root permission (Vim on Linux/macOS).
Useful settings
Type them after : to try them, or put them without the colon in ~/.vimrc to keep them.
:set numberShow line numbers (:set nonumber hides them).
:set relativenumberShow line numbers relative to the cursor line.
:set ignorecase smartcaseCase-insensitive search unless the pattern has a capital letter.
:set hlsearch incsearchHighlight matches and show them while typing.
:set expandtab tabstop=4 shiftwidth=4Use four spaces instead of tab characters.
:set wrap!Toggle line wrapping (a trailing ! toggles any on/off option).
:syntax onTurn on syntax highlighting.
:set clipboard=unnamedplusUse the system clipboard for yank and paste (needs +clipboard support).
:set pastePaste mode: stops auto-indent from mangling pasted text (:set nopaste to turn it off).
:help topicOpen the built-in help, for example :help text-objects.
Ejemplos rápidos
Entradas típicas y los resultados que produce esta herramienta.
Descripción general
Vim es un editor de texto que se maneja con el teclado y que está presente en casi todos los servidores. Funciona distinto de la mayoría de los editores porque tiene modos. Esta chuleta de Vim reúne las teclas y los comandos que más se necesitan: cambiar entre los modos Normal, Insertar y Visual, moverse por el texto, editar, borrar, copiar y pegar.
También cubre la búsqueda y el reemplazo, los objetos de texto como ci" y dap, los registros, las marcas y las macros, las ventanas, las pestañas y los buffers, además de las formas de guardar y salir. Al final hay una lista breve de ajustes útiles para tu .vimrc. Las teclas, los comandos y las descripciones breves se muestran en inglés; en español están la interfaz y esta explicación. Filtra por palabra clave y copia cualquier comando con un clic. La página es texto plano, carga rápido y nada de lo que escribes sale de tu navegador.
¿Por qué usar esta herramienta?
- Consulta una tecla olvidada en segundos
- Incluye todas las formas de guardar y salir, desde :wq hasta ZZ
- Objetos de texto y macros explicados en una línea cada uno
- Filtra por palabra clave, como replace, tab o macro
- Copia comandos y ajustes para tu .vimrc
Funciones
Filtro en vivo
Escribe una palabra clave para ver solo las teclas y secciones que coinciden.
Cómo salir de Vim
:wq, :q!, :x, ZZ y ZQ explicados en una sola sección.
Objetos de texto
Operadores como d, c e y combinados con objetos interiores y exteriores.
Registros y macros
Graba con q, reproduce con @ y guarda varios portapapeles en registros.
Ajustes para .vimrc
Números de línea, opciones de búsqueda, sangrado y ajustes del portapapeles.
Apta para móvil
Las filas se ajustan al ancho, así que la chuleta se lee bien en el teléfono.
Cómo se usa
Elige una sección
Desplázate hasta Moving around, Editing, Search & replace u otro grupo. Los títulos de las secciones están en inglés.
O usa el filtro
Escribe una palabra como "quit" o "macro" en el cuadro "Filtrar esta chuleta".
Comprueba el modo
La mayoría de las teclas funcionan en modo Normal; pulsa Esc primero y lee la nota que hay sobre cada sección.
Copia si lo necesitas
Pulsa Copiar en los ajustes y comandos que quieras pegar en Vim o en tu .vimrc.