From f0512c28cf59a425fd53403440836adf0eea3f5a Mon Sep 17 00:00:00 2001 From: Daniella <137890355+tfemby@users.noreply.github.com> Date: Sun, 4 Feb 2024 18:13:53 +1100 Subject: [PATCH] docs(Autocommands): Remember cursor postion Former users of Vim may have become accustomed to the editors remembering the cursor position This commit adds an example to the documentation to provide similar functionality. --- docs/configuration/autocommands.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/configuration/autocommands.md b/docs/configuration/autocommands.md index 323d5272..9cff57ea 100644 --- a/docs/configuration/autocommands.md +++ b/docs/configuration/autocommands.md @@ -47,3 +47,18 @@ lvim.autocommands = { } } ``` + +A popular feature of Vim is to remember the cursor position. You can achieve similar functionality with the following: + +```lua +lvim.autocommands = { + { + "BufWinEnter", + { + -- Remember cursor position + pattern = "*", + command = 'silent! normal! g`"zv', + }, + } +} +```