David Fishburn wrote:
Vim 7.4.446 Windows 7 32 bit
In an autocmd (BufWritePost) I would like to create a new file and
pass the contents of the current file through some OS program (like
sort for example).
So consider I have this file:
:e dave.txt
3
2
1
Now, when I press :w
My BufWritePost event fires.
In that event I want to create:
dave.txt.post
And I want to send the contents of dave.txt through some external
program (I will sort in this example since it exists on all platforms,
I do not actually want to sort the output or I would use sort() ).
From a terminal I would do something like this to give you the idea I
want:
sort < dave.txt >dave.txt.post
I don't really want to open this file in a Vim buffer, I just want to
write the contents of the file (currently open in Vim) through some
external program and into a new filename.
This is allows me to send the contents of the current buffer through
an external filter, but then I have modified my current buffer (which
I do not want).
%!sort
I thought this would be closer:
%!sort>dave.txt.post
But it does not create dave.txt.post
I assume there is a way to do this, just can't get the syntax correct.
Does dave.txt.post contain the current buffer's contents? If so, you
could probably use exe + system().
Regards,
Chip
--
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.