0

I want :cup in vim command line to turn into :tabdo call MapRunCmd()<CR>

Hope that somebody can help me out

PS: I've tried this nnoremap :cup :tabdo call MapRunCmd()<CR> but didn't like this mapping.
'cause i have to blindly type at a stretch

1
  • 1
    Have a look at :command (Christina makes some points about simplifying your answer) or :cnoreabbrev
    – D. Ben Knoble
    Commented Sep 9, 2021 at 12:07

2 Answers 2

1

You were close with trying a map command, but you want to define a command line mode mapping, not a normal mode mapping.

cnoremap cup tabdo call MapRunCmd()<CR>
2
  • @ChristianBrabandt christian's solution works too.. may come in handy
    – Mega Bang
    Commented Sep 9, 2021 at 12:45
  • if i have more than two commands in a single mapping (separated by |), i would prefer christian's code.. also downside of cnoremap if i don't type the word at a stretch or pause a little bit, vim will trigger wrong for example- almost same words like cup, hackercup .. :hacker[pause]cup
    – Mega Bang
    Commented Sep 9, 2021 at 13:39
1

@ChristianBrabandt 's simple solution

type :Cup in vim command line, it will turn into :tabdo call MapRunCmd()

:com -nargs=0 Cup tabdo call MapRunCmd()
2
  • 1
    why the printf and the TermWrapper function? Doesn't that already do: :com -nargs=0 Cup :tabdo :call MapRunCmd()? Commented Sep 9, 2021 at 11:42
  • thank you very much :) .. updated my solution
    – Mega Bang
    Commented Sep 9, 2021 at 13:05

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.