grep quickfix window question

classic Classic list List threaded Threaded
44 messages Options
123
Reply | Threaded
Open this post in threaded view
|

grep quickfix window question

Jim Green-4
Greetings:

I use grep and :cw to open up a quickfix window that contains all the
matches, I "ENTER" and the cursor jumps to the match in the file.
Could I have the cursor stay in the quick fix window when I "ENTER"?

Thank you!
Jim

--
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
Reply | Threaded
Open this post in threaded view
|

Re: grep quickfix window question

Jürgen Krämer-4

Hi,

Jim Green schrieb:
>
>
> I use grep and :cw to open up a quickfix window that contains all the
> matches, I "ENTER" and the cursor jumps to the match in the file.
> Could I have the cursor stay in the quick fix window when I "ENTER"?

put the following line in your ~/.vimrc

  au FileType QF nmap <buffer> <cr> <cr><c-w><c-p>

This defines a mapping for ENTER whenever a quickfix window is opened.
Instead of just jumping to the match ENTER now also moves back to the
previous window, i.e., the quickfix window.

Regards,
Jürgen

--
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us.     (Calvin)

--
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
Reply | Threaded
Open this post in threaded view
|

Re: grep quickfix window question

Jim Green-4
Thank you Jurgen, somehow it doesn't work for me, hmmm, how do we
debug in this case?

JIm

On Oct 15, 2:09 am, Jürgen Krämer <[hidden email]> wrote:

> Hi,
>
> Jim Green schrieb:
>
>
>
> > I use grep and :cw to open up a quickfix window that contains all the
> > matches, I "ENTER" and the cursor jumps to the match in the file.
> > Could I have the cursor stay in the quick fix window when I "ENTER"?
>
> put the following line in your ~/.vimrc
>
>   au FileType QF nmap <buffer> <cr> <cr><c-w><c-p>
>
> This defines a mapping for ENTER whenever a quickfix window is opened.
> Instead of just jumping to the match ENTER now also moves back to the
> previous window, i.e., the quickfix window.
>
> Regards,
> J rgen
>
> --
> Sometimes I think the surest sign that intelligent life exists elsewhere
> in the universe is that none of it has tried to contact us.     (Calvin)

--
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
Reply | Threaded
Open this post in threaded view
|

Re: grep quickfix window question

Jim Green-4
Also I searched the list and tried a recipe by Tony Mechelynck

if has('autocmd') && has('quickfix')
        au BufWinEnter if &l:buftype == 'quickfix'
                \ | exe 'map <buffer> <F4> <CR><C-W>p'
                \ | endif
endif

Unfortunately it does not work either, appreciate any help here.

On Oct 15, 8:45 am, Jim Green <[hidden email]> wrote:

> Thank you Jurgen, somehow it doesn't work for me, hmmm, how do we
> debug in this case?
>
> JIm
>
> On Oct 15, 2:09 am, Jürgen Krämer <[hidden email]> wrote:
>
> > Hi,
>
> > Jim Green schrieb:
>
> > > I use grep and :cw to open up a quickfix window that contains all the
> > > matches, I "ENTER" and the cursor jumps to the match in the file.
> > > Could I have the cursor stay in the quick fix window when I "ENTER"?
>
> > put the following line in your ~/.vimrc
>
> >   au FileType QF nmap <buffer> <cr> <cr><c-w><c-p>
>
> > This defines a mapping for ENTER whenever a quickfix window is opened.
> > Instead of just jumping to the match ENTER now also moves back to the
> > previous window, i.e., the quickfix window.
>
> > Regards,
> > J rgen
>
> > --
> > Sometimes I think the surest sign that intelligent life exists elsewhere
> > in the universe is that none of it has tried to contact us.     (Calvin)
>
>

--
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
Reply | Threaded
Open this post in threaded view
|

Re: grep quickfix window question

Nikolay Aleksandrovich Pavlov
Ответ на сообщение «Re: grep quickfix window question»,
присланное в 16:47:25 15 октября 2010, Пятница.
Отправитель: Jim Green:

First (``au Filetype'') solution has one error: quickfix filetype is `qf', not
`QF'. If you use
    autocmd Filetype qf nnoremap <buffer> <CR> <CR><C-w>p
everything works fine. The ``au BufWinEnter'' solution lacks pattern, there
should be an asterisk before `if'. And never use `map' where you can use
`noremap'.

Note that if you are going to put this line into vimrc, use that instead:
    augroup vimrcQFCRFix
        " Prevent making duplicate autocommands
        autocmd!
        autocmd Filetype qf nnoremap <buffer> <CR> <CR><C-w>p
    augroup END

Текст сообщения:

> Also I searched the list and tried a recipe by Tony Mechelynck
>
> if has('autocmd') && has('quickfix')
>         au BufWinEnter if &l:buftype == 'quickfix'
>                 \ | exe 'map <buffer> <F4> <CR><C-W>p'
>                 \ | endif
> endif
>
> Unfortunately it does not work either, appreciate any help here.
>
> On Oct 15, 8:45 am, Jim Green <[hidden email]> wrote:
> > Thank you Jurgen, somehow it doesn't work for me, hmmm, how do we
> > debug in this case?
> >
> > JIm
> >
> > On Oct 15, 2:09 am, Jürgen Krämer <[hidden email]> wrote:
> > > Hi,
> > >
> > > Jim Green schrieb:
> > > > I use grep and :cw to open up a quickfix window that contains all the
> > > > matches, I "ENTER" and the cursor jumps to the match in the file.
> > > > Could I have the cursor stay in the quick fix window when I "ENTER"?
> > >
> > > put the following line in your ~/.vimrc
> > >
> > >   au FileType QF nmap <buffer> <cr> <cr><c-w><c-p>
> > >
> > > This defines a mapping for ENTER whenever a quickfix window is opened.
> > > Instead of just jumping to the match ENTER now also moves back to the
> > > previous window, i.e., the quickfix window.
> > >
> > > Regards,
> > > J rgen
> > >
> > > --
> > > Sometimes I think the surest sign that intelligent life exists
> > > elsewhere in the universe is that none of it has tried to contact us.
> > >     (Calvin)

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: grep quickfix window question

Gary Johnson-4
On 2010-10-15, ZyX wrote:

> Jim Green:

> > On Oct 15, 8:45 am, Jim Green <[hidden email]> wrote:

> > > On Oct 15, 2:09 am, Jürgen Krämer <[hidden email]> wrote:
> > > > Hi,
> > > >
> > > > Jim Green schrieb:
> > > > > I use grep and :cw to open up a quickfix window that contains all the
> > > > > matches, I "ENTER" and the cursor jumps to the match in the file.
> > > > > Could I have the cursor stay in the quick fix window when I "ENTER"?
> > > >
> > > > put the following line in your ~/.vimrc
> > > >
> > > >   au FileType QF nmap <buffer> <cr> <cr><c-w><c-p>
> > > >
> > > > This defines a mapping for ENTER whenever a quickfix window is opened.
> > > > Instead of just jumping to the match ENTER now also moves back to the
> > > > previous window, i.e., the quickfix window.

> > > Thank you Jurgen, somehow it doesn't work for me, hmmm, how do we
> > > debug in this case?

> > Also I searched the list and tried a recipe by Tony Mechelynck
> >
> > if has('autocmd') && has('quickfix')
> >         au BufWinEnter if &l:buftype == 'quickfix'
> >                 \ | exe 'map <buffer> <F4> <CR><C-W>p'
> >                 \ | endif
> > endif
> >
> > Unfortunately it does not work either, appreciate any help here.

> First (``au Filetype'') solution has one error: quickfix filetype is `qf', not
> `QF'. If you use
>     autocmd Filetype qf nnoremap <buffer> <CR> <CR><C-w>p
> everything works fine. The ``au BufWinEnter'' solution lacks pattern, there
> should be an asterisk before `if'. And never use `map' where you can use
> `noremap'.

Despite those issues, Jürgen's original version of that autocommand
worked fine for me, so I think Jim's problem with it lies elsewhere.

This is what I did.

    $ vim -N -u NONE
    :set cursorline
    :au FileType QF nmap <buffer> <cr> <cr><c-w><c-p>
    :grep PATTERN *
    :cw

where PATTERN is a string I knew would be found in some files in the
current directory, and 'cursorline' is set to more easily see the
cursor movement in the top buffer.

At this point, moving the cursor in the quickfix window and hitting
Enter works as advertised:  the cursor moves to the correct file and
line in the top window and returns to the quickfix window.

Also, please don't top post to this list.

Regards,
Gary

--
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
Reply | Threaded
Open this post in threaded view
|

Re: grep quickfix window question

Nikolay Aleksandrovich Pavlov
Ответ на сообщение «Re: grep quickfix window question»,
присланное в 17:31:36 15 октября 2010, Пятница.
Отправитель: Gary Johnson:

> This is what I did.
>
>     $ vim -N -u NONE
>
>     :set cursorline
>     :au FileType QF nmap <buffer> <cr> <cr><c-w><c-p>
>     :grep PATTERN *
>     :cw
<...>
> At this point, moving the cursor in the quickfix window and hitting
> Enter works as advertised:  the cursor moves to the correct file and
> line in the top window and returns to the quickfix window.
It does not work in my Vim-7.3 (from Gentoo repos), while with lowercase qf it
does. Maybe you have some other version of vim? In all cases, it is wrong since
`&filetype' is equal to `qf' and not to `QF' and documentation does not say that
filetypes are matched case-insensitively.

> Despite those issues, Jürgen's original version of that autocommand
> worked fine for me, so I think Jim's problem with it lies elsewhere.
Another possible problem: remapping <C-w><C-p> to something is handled by my
variant.

> Also, please don't top post to this list.
You like to scroll down those very long quotes? I copy quotes at the top when I
think it is useful, but you will not convince me to move the whole message
there.

Текст сообщения:

> On 2010-10-15, ZyX wrote:
> > Jim Green:
> > > On Oct 15, 8:45 am, Jim Green <[hidden email]> wrote:
> > > > On Oct 15, 2:09 am, Jürgen Krämer <[hidden email]> wrote:
> > > > > Hi,
> > > > >
> > > > > Jim Green schrieb:
> > > > > > I use grep and :cw to open up a quickfix window that contains all
> > > > > > the matches, I "ENTER" and the cursor jumps to the match in the
> > > > > > file. Could I have the cursor stay in the quick fix window when
> > > > > > I "ENTER"?
> > > > >
> > > > > put the following line in your ~/.vimrc
> > > > >
> > > > >   au FileType QF nmap <buffer> <cr> <cr><c-w><c-p>
> > > > >
> > > > > This defines a mapping for ENTER whenever a quickfix window is
> > > > > opened. Instead of just jumping to the match ENTER now also moves
> > > > > back to the previous window, i.e., the quickfix window.
> > > >
> > > > Thank you Jurgen, somehow it doesn't work for me, hmmm, how do we
> > > > debug in this case?
> > >
> > > Also I searched the list and tried a recipe by Tony Mechelynck
> > >
> > > if has('autocmd') && has('quickfix')
> > >
> > >         au BufWinEnter if &l:buftype == 'quickfix'
> > >        
> > >                 \ | exe 'map <buffer> <F4> <CR><C-W>p'
> > >                 \ | endif
> > >
> > > endif
> > >
> > > Unfortunately it does not work either, appreciate any help here.
> >
> > First (``au Filetype'') solution has one error: quickfix filetype is
> > `qf', not `QF'. If you use
> >
> >     autocmd Filetype qf nnoremap <buffer> <CR> <CR><C-w>p
> >
> > everything works fine. The ``au BufWinEnter'' solution lacks pattern,
> > there should be an asterisk before `if'. And never use `map' where you
> > can use `noremap'.
>
> Despite those issues, Jürgen's original version of that autocommand
> worked fine for me, so I think Jim's problem with it lies elsewhere.
>
> This is what I did.
>
>     $ vim -N -u NONE
>
>     :set cursorline
>     :au FileType QF nmap <buffer> <cr> <cr><c-w><c-p>
>     :grep PATTERN *
>     :cw
>
> where PATTERN is a string I knew would be found in some files in the
> current directory, and 'cursorline' is set to more easily see the
> cursor movement in the top buffer.
>
> At this point, moving the cursor in the quickfix window and hitting
> Enter works as advertised:  the cursor moves to the correct file and
> line in the top window and returns to the quickfix window.
>
> Also, please don't top post to this list.
>
> Regards,
> Gary

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: grep quickfix window question

Jürgen Krämer-4
In reply to this post by Gary Johnson-4

Hi,

Gary Johnson wrote:

>
> Despite those issues, Jürgen's original version of that autocommand
> worked fine for me, so I think Jim's problem with it lies elsewhere.
>
> This is what I did.
>
>     $ vim -N -u NONE
>     :set cursorline
>     :au FileType QF nmap <buffer> <cr> <cr><c-w><c-p>
>     :grep PATTERN *
>     :cw
>
> where PATTERN is a string I knew would be found in some files in the
> current directory, and 'cursorline' is set to more easily see the
> cursor movement in the top buffer.

I tested this on Windows, and I seem to rembember (now) that the case of
the file type is not relevant here.

Regards,
Jürgen

--
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us.     (Calvin)

--
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
Reply | Threaded
Open this post in threaded view
|

Re: grep quickfix window question

Mika Fischer
In reply to this post by Nikolay Aleksandrovich Pavlov
On Fri, Oct 15, 2010 at 15:56, ZyX <[hidden email]> wrote:
>> Also, please don't top post to this list.
> You like to scroll down those very long quotes? I copy quotes at the top when I
> think it is useful, but you will not convince me to move the whole message
> there.

I think the suggestion was to just remove the non-useful quotes
altogether. Like so.

Best,
 Mika

--
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
Reply | Threaded
Open this post in threaded view
|

Re: grep quickfix window question

Jürgen Krämer-4
In reply to this post by Nikolay Aleksandrovich Pavlov

Hi

ZyX wrote:
> Ответ на сообщение «Re: grep quickfix window question»,
> присланное в 17:31:36 15 октября 2010, Пятница.
> Отправитель: Gary Johnson:
>
>> Also, please don't top post to this list.
> You like to scroll down those very long quotes? I copy quotes at the top when I
> think it is useful, but you will not convince me to move the whole message
> there.

then, at least, please don't quote the rest of the mail below your reply,
as you don't add anything new to that part anyway.

Regards,
Jürgen

--
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us.     (Calvin)

--
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
Reply | Threaded
Open this post in threaded view
|

Re: grep quickfix window question

Jim Green-4
In reply to this post by Nikolay Aleksandrovich Pavlov
ZyX's both fixes work. Thank you!
Jim

--
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
Reply | Threaded
Open this post in threaded view
|

Re: grep quickfix window question

Christian Brabandt
In reply to this post by Nikolay Aleksandrovich Pavlov
Hi ZyX!

On Fr, 15 Okt 2010, ZyX wrote:

> > Also, please don't top post to this list.
> You like to scroll down those very long quotes? I copy quotes at the top when I
> think it is useful, but you will not convince me to move the whole message
> there.

And what is preventing you from deleting the old text in the mail, if it
isn't needed?


regards,
Christian

--
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
Reply | Threaded
Open this post in threaded view
|

Re: grep quickfix window question

Jim Green-4
In reply to this post by Gary Johnson-4


On Oct 15, 9:31 am, Gary Johnson <[hidden email]> wrote:

> This is what I did.
>
> $ vim -N -u NONE
> :set cursorline
> :au FileType QF nmap <buffer> <cr> <cr><c-w><c-p>
> :grep PATTERN *
> :cw
>
> where PATTERN is a string I knew would be found in some files in the
> current directory, and 'cursorline' is set to more easily see the
> cursor movement in the top buffer.
>
> At this point, moving the cursor in the quickfix window and hitting
> Enter works as advertised:  the cursor moves to the correct file and
> line in the top window and returns to the quickfix window.

This works well, but looks like set cursorline is global, could I have
a
cursorline just when I do :grep and :cw ?

>
> Also, please don't top post to this list.

Sorry for the top posting, had to use the webbased interface and
forgot..

Thanks!
Jim

--
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
Reply | Threaded
Open this post in threaded view
|

Re: grep quickfix window question

Nikolay Aleksandrovich Pavlov
In reply to this post by Christian Brabandt
Ответ на сообщение «Re: grep quickfix window question»,
присланное в 18:21:38 15 октября 2010, Пятница.
Отправитель: Christian Brabandt:

> And what is preventing you from deleting the old text in the mail, if it
> isn't needed?
It requires more work then moving needed text up.

Текст сообщения:

> Hi ZyX!
>
> On Fr, 15 Okt 2010, ZyX wrote:
> > > Also, please don't top post to this list.
> >
> > You like to scroll down those very long quotes? I copy quotes at the top
> > when I think it is useful, but you will not convince me to move the
> > whole message there.
>
> And what is preventing you from deleting the old text in the mail, if it
> isn't needed?
>
>
> regards,
> Christian

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: grep quickfix window question

Gary Johnson-4
In reply to this post by Nikolay Aleksandrovich Pavlov
On 2010-10-15, ZyX wrote:

> ?????????? ???? ?????????????????? «Re: grep quickfix window question»,
> ???????????????????? ?? 17:31:36 15 ?????????????? 2010, ??????????????.
> ??????????????????????: Gary Johnson:
>
> > This is what I did.
> >
> >     $ vim -N -u NONE
> >
> >     :set cursorline
> >     :au FileType QF nmap <buffer> <cr> <cr><c-w><c-p>
> >     :grep PATTERN *
> >     :cw
> <...>
> > At this point, moving the cursor in the quickfix window and hitting
> > Enter works as advertised:  the cursor moves to the correct file and
> > line in the top window and returns to the quickfix window.
> It does not work in my Vim-7.3 (from Gentoo repos), while with lowercase qf it
> does. Maybe you have some other version of vim? In all cases, it is wrong since
> `&filetype' is equal to `qf' and not to `QF' and documentation does not say that
> filetypes are matched case-insensitively.
>
> > Despite those issues, Jürgen's original version of that autocommand
> > worked fine for me, so I think Jim's problem with it lies elsewhere.
> Another possible problem: remapping <C-w><C-p> to something is handled by my
> variant.

Interesting.  I was testing it using vim-7.3 compiled by me on a
Cygwin system.  I tried the experiment again but using gvim-7.3.2
from the Cream site but without Cream.  The results were the same:
works fine for me despite the flaws in the autocommand.

> > Also, please don't top post to this list.
> You like to scroll down those very long quotes? I copy quotes at the top when I
> think it is useful, but you will not convince me to move the whole message
> there.

If you don't need the rest of the message to set the context for
your reply, don't include it in your reply.

Regards,
Gary

--
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
Reply | Threaded
Open this post in threaded view
|

Re: grep quickfix window question

Jim Green-4
> Interesting.  I was testing it using vim-7.3 compiled by me on a
> Cygwin system.  I tried the experiment again but using gvim-7.3.2
> from the Cream site but without Cream.  The results were the same:
> works fine for me despite the flaws in the autocommand.

I was using vim7.2 on linux QF doesn't work.. also if someones knows
how
to leave some highlight at the place of the match before jumping back
to
the quickfix window, that would be perfect.

Thanks!
Jim

--
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
Reply | Threaded
Open this post in threaded view
|

Re: grep quickfix window question

Nikolay Aleksandrovich Pavlov
In reply to this post by Jim Green-4
Reply to message
<[hidden email]>
with subject «Re: grep quickfix window question»,
sent 18:24:10 15 October 2010, Friday
by Jim Green:

> This works well, but looks like set cursorline is global, could I have
> a
> cursorline just when I do :grep and :cw ?
It is not global, just use `setlocal' instead of `set'.

Original message:

> On Oct 15, 9:31 am, Gary Johnson <[hidden email]> wrote:
> > This is what I did.
> >
> > $ vim -N -u NONE
> >
> > :set cursorline
> > :au FileType QF nmap <buffer> <cr> <cr><c-w><c-p>
> > :grep PATTERN *
> > :cw
> >
> > where PATTERN is a string I knew would be found in some files in the
> > current directory, and 'cursorline' is set to more easily see the
> > cursor movement in the top buffer.
> >
> > At this point, moving the cursor in the quickfix window and hitting
> > Enter works as advertised:  the cursor moves to the correct file and
> > line in the top window and returns to the quickfix window.
>
> This works well, but looks like set cursorline is global, could I have
> a
> cursorline just when I do :grep and :cw ?
>
> > Also, please don't top post to this list.
>
> Sorry for the top posting, had to use the webbased interface and
> forgot..
>
> Thanks!
> Jim

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: grep quickfix window question

Gary Johnson-4
In reply to this post by Jim Green-4
On 2010-10-15, Jim Green wrote:

> On Oct 15, 9:31 am, Gary Johnson <[hidden email]> wrote:
> > This is what I did.
> >
> > $ vim -N -u NONE
> > :set cursorline
> > :au FileType QF nmap <buffer> <cr> <cr><c-w><c-p>
> > :grep PATTERN *
> > :cw
> >
> > where PATTERN is a string I knew would be found in some files in the
> > current directory, and 'cursorline' is set to more easily see the
> > cursor movement in the top buffer.
> >
> > At this point, moving the cursor in the quickfix window and hitting
> > Enter works as advertised:  the cursor moves to the correct file and
> > line in the top window and returns to the quickfix window.
>
> This works well, but looks like set cursorline is global, could I have
> a cursorline just when I do :grep and :cw ?

It looked to me like it was global, too, but ":help cursorline" says
that it's local to the window.  What's happening is that new windows
inherit at least some of the settings of the windows from which they
are created.

If you wanted to set 'cursorline' when doing :grep, you could use
this autocommand:

    au QuickFixCmdPre * set cursorline

I haven't found a way to automatically turn the 'cursorline' off
when the quickfix window is closed, though.

Regards,
Gary

--
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
Reply | Threaded
Open this post in threaded view
|

Re: grep quickfix window question

Nikolay Aleksandrovich Pavlov
Reply to message «Re: grep quickfix window question»,
sent 19:04:54 15 October 2010, Friday
by Gary Johnson:

> It looked to me like it was global, too, but ":help cursorline" says
> that it's local to the window.  What's happening is that new windows
> inherit at least some of the settings of the windows from which they
> are created.
No, it is partially false. The problem here is that `:set' command sets both
global and local values, you should use `:setlocal' to set only local value
without touching global. More info is available in :h local-options. The
following code works just fine:
    autocmd Filetype qf setlocal cursorline

Original message:

> On 2010-10-15, Jim Green wrote:
> > On Oct 15, 9:31 am, Gary Johnson <[hidden email]> wrote:
> > > This is what I did.
> > >
> > > $ vim -N -u NONE
> > >
> > > :set cursorline
> > > :au FileType QF nmap <buffer> <cr> <cr><c-w><c-p>
> > > :grep PATTERN *
> > > :cw
> > >
> > > where PATTERN is a string I knew would be found in some files in the
> > > current directory, and 'cursorline' is set to more easily see the
> > > cursor movement in the top buffer.
> > >
> > > At this point, moving the cursor in the quickfix window and hitting
> > > Enter works as advertised:  the cursor moves to the correct file and
> > > line in the top window and returns to the quickfix window.
> >
> > This works well, but looks like set cursorline is global, could I have
> > a cursorline just when I do :grep and :cw ?
>
> It looked to me like it was global, too, but ":help cursorline" says
> that it's local to the window.  What's happening is that new windows
> inherit at least some of the settings of the windows from which they
> are created.
>
> If you wanted to set 'cursorline' when doing :grep, you could use
> this autocommand:
>
>     au QuickFixCmdPre * set cursorline
>
> I haven't found a way to automatically turn the 'cursorline' off
> when the quickfix window is closed, though.
>
> Regards,
> Gary

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: grep quickfix window question

Gary Johnson-4
On 2010-10-15, ZyX wrote:

> Reply to message «Re: grep quickfix window question»,
> sent 19:04:54 15 October 2010, Friday
> by Gary Johnson:
>
> > It looked to me like it was global, too, but ":help cursorline" says
> > that it's local to the window.  What's happening is that new windows
> > inherit at least some of the settings of the windows from which they
> > are created.
> No, it is partially false. The problem here is that `:set' command sets both
> global and local values, you should use `:setlocal' to set only local value
> without touching global. More info is available in :h local-options. The
> following code works just fine:
>     autocmd Filetype qf setlocal cursorline

":help cursorline" says specifically that this option is "local to
window".

Try the following in a new Vim instance.

    :new
    :set cursorline
    :new
    :wincmd b
    :new

Note that the upper two windows show a cursor line while the lower
two windows do not.  If ":set cursorline" was setting a global
value, I would expect a cursor line to appear in all windows.

Regards,
Gary

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