1

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

NB:

There is an typo here, it shall be OpenBookmark,

  • 1
    Are looking for :execute? – Luc Hermitte Nov 23 '18 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 Nov 23 '18 at 17:19
  • 1
    It's :execute 'echom '.varname – Luc Hermitte Nov 23 '18 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> – Luc Hermitte Nov 23 '18 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 Nov 28 '18 at 9:19
0

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, privacy policy and cookie policy

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