chentoast/marks.nvim

Hide a certain mark

primeapple opened this issue · 2 comments

Hi, first of all, thank you alot for this amazing plugin.

I have a remapping, that sets a temporary mark:

nnoremap <silent> J mzJ`z

This basically keeps the current cursor x position while joining a line.
However, this does set mark z, which I now have flying around everywhere.
Is there an option to hide this? I tried deleting it afterwards with

nnoremap <silent> J mzJ`z:delm z<CR>

But now I have to press u twice if I want to undo something...

There are two ways to get around this.

The first option would be to use a builtin mark instead of a named mark; for example, you could do m'J'', to use the builtin ' mark instead of z. If you exclude ' from being tracked by the plugin, then it won't show up in the sign column.

The other option would be to instead write a function that saves the cursor position and then restores it, without using marks. For example, in lua you would write it like this:

local function join()
  local pos = vim.api.nvim_win_get_cursor(0)
  vim.cmd "norm! J"
  vim.api.nvim_win_set_cursor(0, pos)
end

you can then bind your key to invoke the function.

This is an amazing answer :)
Thank you!