Below is an excerpt from my
~/.vimrc that contains the vimscript code I implemented by building upon the very good "remap nothing" idea from the already existing answer provided by @the_velour_fog.
I improved the idea and the implementation further to be almost something like "change nothing". Just hit ' or ` as usual, and you'll get the list to select a mark from, but nothing else changes, not even the error messages displayed when trying to jump to unset or unknown marks.
Actually, if you press ' + a quickly, for example, or even ' + Esc depending on the configured
ttimeoutlen value, you may even not notice the list of marks being displayed for a fraction of a second, but still have the desired jump operation performed or canceled, or the original error message displayed. That's how much the original behavior remains unchanged.
Here's the vimscript code:
" Display a list of marks and allow their easy selection, without
" remapping any keys or changing the original vim behavior, down
" to the error messages produced for unknown marks
function ListSelect(command, jump)
echo "Enter mark (ESC to cancel): "
let mark = nr2char(getchar())
if mark !=# "\e"
execute "normal! g" .. a:jump .. mark
echo substitute(v:exception, "^Vim(.*):", "", "")
nnoremap <silent> ' :call ListSelect("marks", "'")<CR>
nnoremap <silent> ` :call ListSelect("marks", "`")<CR>
As visible in the vimscript code and as already described above, this version retains the ability to use Esc to cancel the whole operation, and it still produces the same
E20: Mark not set and
E78: Unknown mark error messages, without throwing any "executing function failed" errors at the user.
This version also produces a prompt message that looks just like all such messages produced by
vim itself, furthering the "change nothing" approach.