Lets say I jump to mark with ]' and I want to remove it, how can I do it without typing :delmarks a?

3 Answers 3


You can delete all a-z marks on the current line using this function:

function! Delmarks()
    let l:m = join(filter(
       \ map(range(char2nr('a'), char2nr('z')), 'nr2char(v:val)'),
       \ 'line("''".v:val) == line(".")'))
    if !empty(l:m)
        exe 'delmarks' l:m

and with a map

nnoremap <silent> dm :<c-u>call Delmarks()<cr>

I'm going to swim against the stream on this one.

Just don't worry about it.

Marks are pretty ephemeral and there are bunch of marks Vim automatically maintains like '[, '', and '. Humans are typically very bad at bookkeeping so we typically use only a few registers and a few marks. I personally only use a few a-z marks (typically 'm) and often only in few immediate contexts e.g. macros or jumping between a few spots. Your workflow maybe different, but I see no reason to "clean up" the marks.

Now to answer your question:

nnoremap dm :execute 'delmarks '.nr2char(getchar())<cr>

Now you can do dma to delete mark 'a.

Or to delete all marks on the current line:

command! Delmarks silent execute 'delmarks '.join(map(filter(filter(map(split(execute('marks'),"\n"),'split(v:val)'), 'v:val[1]==line(".")&&v:val[0]!~#"[A-Z]"'), 'v:val[1]==line(".")&&v:val[0]!~#"[A-Z]"'), 'v:val[0]'))

Just map this to a key to so you don't have to type out :Delmarks.

  • I work with large source files and quite often need to move bookmark few lines up or down. Since @Mass posted similar answer first I will accept his. Thank you for your opinion.
    – noee
    Oct 20, 2017 at 21:45

To delete a mark you can use :delmark it can be shortened to :delm. If you really want something shorter you can map a function which asks for an input but it's not really a common practice to have a map which takes a parameter or ask for an input.

function! MarkDelete()
    call inputsave()
    let l:mark = input("Mark to del: ")
    call inputrestore()
    execute 'delmark '.l:mark

Now just map it:

nnoremap <F2> call MarkDelete()<CR>

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.