0

-buffer flag in :command adds a command to the current buffer but how can I add command to a buffer by a given buffer number.

2
  • I don't think there's a direct way to define a command to a single buffer that's not the current buffer... If you want to accomplish that, I think you need to switch to the buffer you want the command to apply to, create the command, and switch back or otherwise undo the action (e.g. close a split if you opened one for the buffer.)
    – filbranden
    Nov 23 at 22:53
  • 1
    if the buffer is displayed in a different window, you could use win_execute() Nov 24 at 7:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.