Bug#529087: vim: please implement a --drop-empty option
Francesco Poli
frx at firenze.linux.it
Thu Jul 30 21:13:04 UTC 2009
On Thu, 30 Jul 2009 16:00:57 +0200 James Vega wrote:
[...]
> On Sun, May 17, 2009 at 07:09:49PM +0200, Francesco Poli (t1000) wrote:
> > This option could be named "--drop-empty" or something like that.
> > It would work as follows: when vim (or view, or ...) is started with
> > this option, any newly created buffer
>
> A buffer is created for every file you tell Vim to open, regardless of
> whether the file exists on disk yet or whether the file has any
> contents.
I am aware of this: my proposed option would indeed modify this
behavior, when it is useful to immediately close empty buffers...
>
> > is checked and automatically closed if found to be empty.
> >
> > This way, my use of View as a pager would automatically exit (with
> > 0 exit status, of course, because nothing went wrong) when the output
> > of some_command is empty:
> >
> > $ some_command | view --drop-empty -
> >
> > [snip]
> > This could be useful when you want to edit already existing files,
> > without creating new ones, and you do *not* know in advance which
> > files exist (among the ones of a given list).
>
> Vim notifies you that the buffer doesn't have a corresponding file on
> disk already.
What do you mean "Vim notifies me"?
When I issue the following command:
$ some_command | view -
there *never* is a corresponding file for the newly opened buffer, IIUC.
When some_command writes something to its stdout, I can use View as a
pager to visualize this output. On the other hand, when some_command
writes nothing to its stdout, View shows me the VIM "splash screen" and
I have to manually issue the :q command to exit.
I would like to have an option to automatically exit in the latter case.
>
> > Could this new feature be implemented?
> > Please forward this feature request to upstream, if appropriate.
>
> The feature is of marginal use and can be achieved through scripting.
> Tagging the bug as wontfix.
What's the best way to check whether the current buffer is empty in a
VIM script (that I can invoke with "view -s dropempty.vim")?
I searched in VIM documentation, but failed to find anything simpler
than
$ cat dropempty.vim
:if line2byte(line("$") + 1) == 2
: q
:endif
This script seems to work, but, frankly speaking, it's contorted,
inelegant, and needlessly complicated.
Moreover, it's a bit slow: I am able to see the "splash screen" shortly
flashing, before View exits.
Any better solutions?
--
New location for my website! Update your bookmarks!
http://www.inventati.org/frx
..................................................... Francesco Poli .
GnuPG key fpr == C979 F34B 27CE 5CD8 DC12 31B5 78F4 279B DD6D FCF4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-vim-maintainers/attachments/20090730/7fc46a9d/attachment-0001.pgp>
More information about the pkg-vim-maintainers
mailing list