3

When I run :marks it lists all the marks including the standard Vim marks. This is somehow distracting.

Is there a way to list only my marks that I created using m-X for example?

4
  • 1
    :marks a-z should work Commented Oct 8, 2020 at 11:03
  • 1
    For me it doesn't work. It just shows 'a' mark and doesn't show 'b' and 'c'. Although they are shown by just :marks Commented Oct 8, 2020 at 11:59
  • 1
    I found that :marks a-b will show 'a' and 'b'. :marks a-c will show 'a' and 'c'. :marks a-d will only show 'a'. As far as I read, this should list marks from a to d. If I run :marks abcd it will list 'a', 'b', and 'c' which all I have. So it looks like this is the best solution Commented Oct 8, 2020 at 12:05
  • it would be amazing if someone showed how to do this using FuzzyFinder (which would list the marks, by providing an interactive menu to choose one of them to go to, which one could shortcut by typing the mark character and hitting enter.) Although on reflection I guess Salahuddin Ahmed's answer is just as good. Commented Jan 11, 2023 at 15:52

2 Answers 2

4

You can define a custom command like this, that will only show the lowercase marks a-z:

:com :MyMarks :sil! marks abcdefghijklmnopqrstuvwxyz
2

I end up having this in my vimrc

nnoremap <silent> ,m :marks abcdefghijklmnopqrstuvwxyz<CR>:normal! `

With this, ,m vim lists all my marks and then I only have to type the mark that I want to jump to, and hit enter.

The 'normal' command executes its command-line args as if you had pressed those keys in normal mode. We deliberately don't add a <CR> to this, part so that the user is presented with a half-typed command:

:normal! '

The ' at the end is the start of a 'go to mark' command, hence the user can just press 'A' (or whatever) and then enter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.