Tuesday, April 26, 2022

syntax for "map key test?'cmd1':'cmd2'|:cmd3|:cmd4"

I have the following (pseudo code) mapping working:
nmap <expr> key some-expr ?
  \ 'cmd1<Bar>:cmd3<CR><Bar>:cmd4<CR>' :
  \ 'cmd2<Bar>:cmd3<CR><Bar>:cmd4<CR>'

As you can see the conditional selects between cmd1 and cmd2,  but both execute cmd3 and cmd4.
I'd like to move cmd3 and cmd4 outside of the conditional as in
nmap <expr> key some-expr?'cmd1':'cmd2'<Bar>:cmd3<CR><Bar>:cmd4<CR>
The problem is I get cmd1 or cmd2 to execute, but never cmd3 or cmd4.
I know I could move this to a function but I'd like to understand the syntax.

Thank you

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/efb87320-014d-432f-afc6-12e530f1decbn%40googlegroups.com.

No comments: