Wednesday, August 17, 2011

Re: Update quickfix list, recall vimgrep expression

Hi Paul!

On Mi, 17 Aug 2011, Paul wrote:

> On Aug 17, 3:03 pm, Paul <paul.domas...@gmail.com> wrote:
> > On Aug 17, 10:14 am, Paul <paul.domas...@gmail.com> wrote:
> > > On Aug 17, 1:44 am, "Christian Brabandt" <cbli...@256bit.org> wrote:
> > > > On Wed, August 17, 2011 4:00 am, Paul wrote:
> > > > > I am using Vim 7.3 on Windows 7 Enterprise 32-bit.
> >
> > > > > I'm use the quickfix list a lot with vimgrep.  I swap between lists by
> > > > > the :cold and :cnew commands.  However, after much editing, the lists
> > > > > get out-of-date.  When I cruise between lists, I often forget the
> > > > > vimgrep expression, and the command history q: doesn't help after much
> > > > > editing and flipping between lists.  Is there a way to: (1) recall the
> > > > > vimgrep expression associated with the currently viewed quickfix list,
> > > > > and (2) refresh the list by effectively redoing the vimgrep?  For #2,
> > > > > I can see advantages and disadvantages to putting the repeated vimgrep
> > > > > onto the command history as a new entry.
> >
> > > > I think since Vim 7.3 the quickfix window should always have the variable
> > > > w:quickfix_title set which contains the command that created this list.
> > > > Unfortunately, until at least patch 7.3.280 that variable wasn't always
> > > > updated so often did contain only the first command, but that patch
> > > > should have fixed that.
> >
> > > > The $VIMRUNTIME/ftplugin/qf.vim should also set the statusline in the
> > > > quickfix window to display that variable.
> >
> > > > Assuming you have been in the quickfix window before and are now in
> > > > another window, something like that should be possible to redo
> > > > the command, that created the quickfix window:
> >
> > > > :exe getwinvar(winnr('#'), 'quickfix_title')
> >
> > > OK, thanks, Christian.  Many new vim concepts (to me) in that
> > > example...I'll explore it further.
> >
> > I sourced that file manually.  I can't say that I understand it all,
> > but the most relevant line seems to be
> >
> > setlocal stl=%q%{exists('w:quickfix_title')?\ '\ '.w:quickfix_title\ :
> > \ ''}
> >
> > In any case, it seems to require that the cursor doesn't *have* to be
> > in the quickfix window prior to sourcing the file, but the statusline
> > doesn't update until I re-issue ":copen".
> >
> > It helps alot....being greedy, I was wondering:
> >
> > Is there a simple way to get the statusline to update automatically?
> >
> > Also, short of placing an source command in .vimrc, is there a way to
> > ensure that this plugin runs automatically?  I mean something more
> > elegant than dropping it in my vim/plugin/ directory.  My runtime path
> > already "c:\Program Files\Vim\vim73".  The full path of the plugin is
> > "c:\Program Files\Vim\vim73\ftplugin\qf.vim".  It should load already,
> > but doesn't seem to.
>
> My quick and dirty solution is:
>
> command QF source c:/Program\ Files/Vim/vim73/ftplugin/qf.vim

A simple
filetype plugin on
in your .vimrc should suffice, that the file should be read
automatically.

regards,
Christian
--
Schwimmer gegen den Strom dürfen nicht erwarten, daß dieser seine
Richtung ändert.
-- Stanislaw Jerzy Lec (eig. S. J. de Tusch-Letz)

--
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

No comments: