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

# Miten voin määrittää omia Vim-makroja vimrc-tiedostossa Overleafissa?

## Johdanto

Overleaf tarjoaa Vim- ja Emacs-näppäinsidonnat, jotka voidaan ottaa käyttöön [projektivalikosta](/latex/fi/tietopankki/148-using-the-overleaf-project-menu.md#keybindings). Koska editori emuloi näitä näppäinsidontoja (eli todellista Vimiä tai Emacsia ei ole käynnissä), Vimissä tavallisia tapoja lisätä uusia sidontoja ei voi käyttää Overleafissa Tampermonkeyn avulla. Tässä näytämme keinoja, joiden pitäisi auttaa kiertämään tämän rajoituksen.

### Overleafin käytäntö Tampermonkeyn ja UserScriptsien suhteen

Huomaa, että Overleaf ei tue UserScripts- ja Tampermonkey-skriptejä virallisesti ja että mukautetut skriptit voivat häiritä Overleafin normaalia toimintaa. Jos käytät tällaisia skriptejä ja sinun täytyy ottaa yhteyttä Overleafiin teknisen tuen saamiseksi, pyydämme ystävällisesti, että poistat käytöstä kaikki Tempermonkey-skriptit ja tarkistat, paraneeko tilanne. Jos skriptien poistaminen käytöstä ei ratkaise ongelmaasi, ole hyvä ja [ota yhteyttä](https://www.overleaf.com/contact) pyydä apua.

## Tampermonkey UserScript

Huomaa, että tämä on *sisällä* virallisesti tuettu menetelmä ja käyttöliittymä saattaa muuttua tulevaisuudessa, mistä johtuu “`UNSTABLE_editor`”-nimitys.

```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;

    // lisää mukautetut näppäinsidonnat - insert-tila on voimassa lisäystilassa
    CodeMirrorVim.Vim.map("jj", "<Esc>", "insert");
    // normaali tila on voimassa poistuttaessa insert-tilasta
    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/fi/tietopankki/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.
