www-gem words

Automatically save your position in vim on closing

Published on

vim If you spend quite some times writing in your preferred text editor, you know how cumbersome it is to look where you were the last time you access a document.

These days are over with this simple code to be added to your config file (the format here is in lua):

vim.cmd [[ augroup save_cursor_position
autocmd BufReadPost * call setpos(".", getpos("'\""))
augroup END

You may appreciate to be able to catch-up on your work where you left it. This small piece of code will save the cursor position automatically for you on document closing. So when you reopen them, you will be placed exactly where you were at closing time.

Thanks for your read. Hope it's been useful to you.

Interact with this post using Mastodon or

Comment on wwwgem's post

Copy and paste this URL into the search field of your favourite Fediverse app or the web interface of your Mastodon server.

✄ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈

More food for thoughts? Check other posts about: #Vim