On Wednesday, February 1, 2017 at 9:20:18 AM UTC-6, Neil Watson wrote:
> Greetings,
>
> High level goal: Optionally have vim run the current buffer right after writing
> it to disk.
>
> A setting like this does make the post write run work, but on all buffers.
>
> au BufWritePost * !./%
>
> How can I make this work on just the current buffer and how can a quickly
> toggle it on or off with less typing? I did try making a function, but calling
> it did nothing:
>
> if exists("b:Autorun")
> au BufWritePost * !./%
> endif
For your attempted method you would just need to move the check to *within* the autocmd:
au BufWritePost * if exists("b:Autorun") | !./% | endif
A better method would probably be to use a buffer-local autocmd (:help autocmd-buffer-local):
au BufWritePost <buffer> !./%
and then get rid of it:
au! BufWritePost <buffer>
Map these to a keypress or a user-defined command and you're ready to go.
--
--
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.
For more options, visit https://groups.google.com/d/optout.
Wednesday, February 1, 2017
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment