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
    Sep 9 at 12:07
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
    Sep 9 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
    Sep 9 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()? Sep 9 at 11:42
  • thank you very much :) .. updated my solution
    – Mega Bang
    Sep 9 at 13:05

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.