vim : <silent> nmap

JuanPablo picture JuanPablo · Aug 29, 2011 · Viewed 9.1k times · Source

In vim I have this nmap

nmap <silent> ,mu : marks ABCDEFGHIJKLMNOPQRSTUVWXYZ<CR>

If I don´t have Upper marks and try ,mu I get

E283: No marks matching "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

why don't show the Error output ?

Answer

ZyX picture ZyX · Aug 29, 2011

Try

 nnoremap <silent> ,mu :execute "try\nmarks ABCDEFGHIJKLMNOPQRSTUVWXYZ\ncatch /\\V\\^Vim(marks):E283:/\nendtry"<CR>

By the way, is there a reason for writing :nmap instead of :nnoremap? You should not do this if you don't have a reason unless you want to run in the situation where you can't predict what will be the result of adding another mapping (directly to vimrc or by installing a plugin).

Edit (sehe)

To make things more readable, I'd suggest using a snippet like this in your $MYVIMRC:

function! ShowGlobalMarks()
    try
        marks ABCDEFGHIJKLMNOPQRSTUVWXYZ
    catch /E283:/
    endtry
endfu

nnoremap <silent> ,mu :call ShowGlobalMarks()<CR>