reverting keymaps for location-list buffer

41 views
Skip to first unread message

Stephan Sahm

unread,
Apr 30, 2015, 8:11:33 AM4/30/15
to v...@vim.org
Dear all,

I remapped <CR> and I really like my remapping. There are however some problems
For quickfix buffers I found this:

autocmd BufReadPost quickfix nnoremap <CR> <CR>

is there something similar for location-list buffers?

thanks in advance,

best,
Stephan

John Beckett

unread,
May 2, 2015, 2:45:28 AM5/2/15
to vim...@googlegroups.com
Stephan Sahm wrote:
> I remapped <CR> and I really like my remapping. There are
> however some problems For quickfix buffers I found this:
>
> autocmd BufReadPost quickfix nnoremap <CR> <CR>
>
> is there something similar for location-list buffers?

To make Enter work normally in a quickfix window, rather than
rely on auto commands, you can create file:

~/vimfiles/ftplugin/qf.vim

containing the single line:

nnoremap <buffer> <CR> <CR>

The above is all that is needed to make Enter behave as Enter
in quickfix and local-list buffers (in normal mode, which is
all you need).

John


Stephan Sahm

unread,
May 2, 2015, 3:19:54 AM5/2/15
to vim...@googlegroups.com
Dear John,

thank you very much for the answer and sorry for the doubled topic
(I was used to mailinglists and a kind of immediate feedback so got confused by the topic structure of google groups. I wrote a mail and meantime because of no response also posted a topic - where I still got no response. Hours later both were put online)

put the line into the mentioned file,
➜  ~  cat
​~/​
vimfiles/ftplugin/qf.vim 
nnoremap <buffer> <CR> <CR>
 
but still get a "E21: Cannot make changes, 'modifiable' is off" due to my remapping <CR> o<CR>, so it wasn't written back.
(this happens in a location-list window opened by syntastic)

is the vimfiles folder maybe wrong? must it be somewhere under .vim/ maybe?

best,
Stephan



--
--
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+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

John Beckett

unread,
May 2, 2015, 3:56:43 AM5/2/15
to vim...@googlegroups.com
Stephan Sahm wrote:
> is the vimfiles folder maybe wrong?
> must it be somewhere under .vim/ maybe?

Sorry, my confusion. For a Unix-based system, create file
(you may have to create the directory first):

~/.vim/ftplugin/qf.vim

containing the single line:

nnoremap <buffer> <CR> <CR>

The above should make pressing Enter work as expected in
quickfix and local-list buffers. With the cursor in one of those
windows, enter the following command to see what mapping is in
effect, and where it was set. You only care about the "n" line
which is the mapping for normal mode.

:verbose map <CR>

John

Stephan Sahm

unread,
May 2, 2015, 4:01:46 AM5/2/15
to vim...@googlegroups.com
works like a charm - impressively easy solution =)

thank you very much and have a nice weekend,
best,
Stephan


John

Stephan Sahm

unread,
May 2, 2015, 4:06:10 AM5/2/15
to vim...@googlegroups.com
an afterglow:
is there a listing about which .vim file belongs to which standard feature? where have you known from that it is qf.vim?

Ben Fritz

unread,
May 3, 2015, 11:24:59 PM5/3/15
to vim...@googlegroups.com
On Saturday, May 2, 2015 at 3:06:10 AM UTC-5, Stephan Sahm wrote:
> an afterglow:
> is there a listing about which .vim file belongs to which standard feature? where have you known from that it is qf.vim?
>
>

Every location list or error list is a "quickfix" list, which always has filetype of "qf".

Assuming you have filetype plugins turned on, placing a file "qf.vim" in the ftplugin folder, will make that file get sourced any time a buffer's filetype is set to "qf".

Thus, to override settings or mappings for locations lists or error lists, it is easy to do this using the "qf.vim" file.

Stephan Sahm

unread,
May 4, 2015, 2:15:26 AM5/4/15
to vim...@googlegroups.com
Dear Ben,

thank you very much for the explanation. One mystical thing less about vim =).

best wishes,
Stephan


Reply all
Reply to author
Forward
0 new messages