1

I have a shell script meant to run within vim. I'd like it to insert the name of the file I'm editing but I can't figure out how to do it. Is there a way to, perhaps, call bufname() from within a shell script?

2
  • Could you pass the buffer name as an argument of your shell script? Mar 12 at 19:05
  • 1
    @VivianDeSmedt I probably could, but that would be more keystrokes than inserting it after the script runs. Shift-R-Ctrl-R-% is fairly instant. I'm just looking for a way to be even lazier.
    – MDeBusk
    Mar 12 at 19:41

1 Answer 1

2

You could do use environment variables:

let $BUFNAME=@%
!yourshellscript.sh

Use $BUFNAME within your shell script.

Remark: you could set an autocmd to set $BUFNAME when you switch to a window.

2
  • Well... that was easy. Thank you!
    – MDeBusk
    Mar 12 at 19:47
  • 1
    Thanks for the feedback :-) Mar 12 at 19:48

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.