I need to define variables who can hold number or strings. Those variables would be used later in the key mapping

for example

let bookMark=Lib7 //:echo boomMark do give out Lib7
nmap gb :<c-u>NERDTree<CR>:OpenBookMark 'bookmark'<Cr> //not working
nmap gb :<c-u>NERDTree<CR>:OpenBookMark bookmark<Cr> //not working


There is an typo here, it shall be OpenBookmark,

  • 1
    Are looking for :execute? Commented Nov 23, 2018 at 17:06
  • @LucHermitte yes but no. still not working, I have the error ` OpenBookMark :execute "echom bookmark" `. I think the variable is run time evalued
    – SLN
    Commented Nov 23, 2018 at 17:19
  • 1
    It's :execute 'echom '.varname Commented Nov 23, 2018 at 17:20
  • 2
    ?? I though you knew that :echom isn't :OpenBookmark. If you wish to feed a variable name into :OpenBookmark, it becomes: nnoremap gb :<c-u>NERDTree<CR>:exe 'OpenBookMark '.bookmark<Cr> Commented Nov 23, 2018 at 17:36
  • 1
    @SLN please post your edit as an answer and accept it. This way future readers will know that your question has been answered and might be useful for them too.
    – statox
    Commented Nov 28, 2018 at 9:19

1 Answer 1


According to @Luc Hermitte's answer, the correct version are

nnoremap gb :NERDTree<CR>:exe 'OpenBookmark '.bookmark<Cr> or

nnoremap gb :NERDTree<CR>:exe "OpenBookmark" bookmark<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.