> 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/da/vidensbase/049-how-can-i-define-custom-vim-macros-in-a-vimrc-file-on-overleaf.md).

# Hvordan kan jeg definere brugerdefinerede Vim-makroer i en vimrc-fil i Overleaf?

## Introduktion

Overleaf tilbyder Vim- og Emacs-tastaturgenveje, som kan aktiveres i [projektmenuen](/latex/da/vidensbase/148-using-the-overleaf-project-menu.md#keybindings). Men da disse tastaturgenveje emuleres af editoren (dvs. der kører ingen rigtig Vim eller Emacs), er det ikke muligt at bruge Vims standardmetoder til at tilføje nye inden for Overleaf ved hjælp af Tampermonkey. Her viser vi måder, der bør hjælpe med at overvinde denne begrænsning.

### Overleafs politik om Tampermonkey og UserScripts

Vær opmærksom på, at UserScripts og Tampermonkey ikke officielt understøttes af Overleaf, og at brugerdefinerede scripts kan forstyrre Overleafs normale drift. Hvis du bruger sådanne scripts og har brug for at kontakte Overleaf for teknisk support, beder vi dig venligst deaktivere eventuelle Tampermonkey-scripts og kontrollere, om situationen forbedres. Hvis deaktivering af scriptsene ikke løser dit problem, bedes du [kontakte os](https://www.overleaf.com/contact) for hjælp.

## Tampermonkey UserScript

Bemærk, at dette er *ikke* en officielt understøttet metode, og grænsefladen kan ændre sig i fremtiden, derfor “`UNSTABLE_editor`”-navngivningen.

```latex
// ==UserScript==
// @name         Overleaf-editorens brugerdefinerede VIM-tastaturgenveje
// @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;

    // tilføj brugerdefinerede tastaturgenveje - indsættelsestilstand gælder ved indsætning
    CodeMirrorVim.Vim.map("jj", "<Esc>", "insert");
    // normaltilstand gælder, mens der er i escape-tilstand
    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/da/vidensbase/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.
