> For the complete documentation index, see [llms.txt](https://overleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://overleaf-pro.ayaka.space/latex/es/base-de-conocimientos/049-how-can-i-define-custom-vim-macros-in-a-vimrc-file-on-overleaf.md).

# ¿Cómo puedo definir macros personalizadas de Vim en un archivo vimrc en Overleaf?

## Introducción

Overleaf proporciona asignaciones de teclas de Vim y Emacs que se pueden activar en el [menú del proyecto](/latex/es/base-de-conocimientos/148-using-the-overleaf-project-menu.md#keybindings). Sin embargo, como estas asignaciones de teclas son emuladas por el editor (es decir, no hay ninguna instancia real de Vim o Emacs en ejecución), no es posible usar los métodos estándar de Vim para añadir nuevas dentro de Overleaf usando Tampermonkey. Aquí mostramos formas que deberían ayudar a superar esta limitación.

### Política de Overleaf sobre Tampermonkey y UserScripts

Tenga en cuenta que UserScripts y Tampermonkey no cuentan con soporte oficial de Overleaf y que los scripts personalizados pueden interferir con el funcionamiento normal de Overleaf. Si está utilizando dichos scripts y necesita ponerse en contacto con Overleaf para obtener asistencia técnica, le rogamos que desactive cualquier script de Tempermonkey y compruebe si la situación mejora. Si desactivar los scripts no resuelve su problema, por favor [contactarnos](https://www.overleaf.com/contact) para obtener ayuda.

## UserScript de Tampermonkey

Tenga en cuenta que este es *contiene* un método oficialmente compatible y la interfaz puede cambiar en el futuro, de ahí la`UNSTABLE_editor`" de “naming”.

```latex
// ==UserScript==
// @name         Overleaf Editor Custom VIM Keybindings
// @namespace    http://tampermonkey.net/
// @version      0.1
// @match        https://www.overleaf.com/project/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    window.addEventListener("UNSTABLE_editor:extensions", (event) => {
    const { CodeMirror, CodeMirrorVim, extensions } = event.detail;

    // añadir asignaciones de teclas personalizadas - el modo de inserción se aplica al insertar
    CodeMirrorVim.Vim.map("jj", "<Esc>", "insert");
    // el modo normal se aplica mientras está en modo escapado
    CodeMirrorVim.Vim.map("h", "j", "normal");
    });
})();
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://overleaf-pro.ayaka.space/latex/es/base-de-conocimientos/049-how-can-i-define-custom-vim-macros-in-a-vimrc-file-on-overleaf.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
