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

# Jak mogę zdefiniować własne makra Vima w pliku vimrc w Overleaf?

## Wstęp

Overleaf udostępnia skróty klawiaturowe Vim i Emacs, które można włączyć w [menu projektu](/latex/pl/baza-wiedzy/148-using-the-overleaf-project-menu.md#keybindings). Jednak ponieważ te skróty klawiaturowe są emulowane przez edytor (tzn. nie działa tam prawdziwy Vim ani Emacs), nie można w Overleaf użyć standardowych metod Vima do dodawania nowych skrótów za pomocą Tampermonkey. Poniżej pokazujemy sposoby, które powinny pomóc obejść to ograniczenie.

### Zasady Overleaf dotyczące Tampermonkey i UserScripts

Informujemy, że UserScripts i Tampermonkey nie są oficjalnie obsługiwane przez Overleaf, a własne skrypty mogą zakłócać normalne działanie Overleaf. Jeśli korzystasz z takich skryptów i potrzebujesz skontaktować się z Overleaf w sprawie pomocy technicznej, uprzejmie prosimy o wyłączenie wszelkich skryptów Tempermonkey i sprawdzenie, czy sytuacja się poprawia. Jeśli wyłączenie skryptów nie rozwiąże problemu, prosimy [skontaktować się z nami](https://www.overleaf.com/contact) o pomoc.

## UserScript Tampermonkey

Należy pamiętać, że jest to *nie* metoda oficjalnie wspierana, a interfejs może ulec zmianie w przyszłości, stąd „`UNSTABLE_editor`” w nazwie.

```latex
// ==UserScript==
// @name         Niestandardowe skróty klawiaturowe VIM w edytorze Overleaf
// @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;

    // dodaj niestandardowe skróty klawiaturowe - tryb wstawiania działa podczas wstawiania
    CodeMirrorVim.Vim.map("jj", "<Esc>", "insert");
    // tryb normalny obowiązuje po wyjściu z trybu wstawiania
    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/pl/baza-wiedzy/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.
