How to map keys in vim differently for different kinds of buffers

Posted by Yogesh Arora on Stack Overflow See other posts from Stack Overflow or by Yogesh Arora
Published on 2010-03-12T16:20:29Z Indexed on 2010/03/19 20:01 UTC
Read the original article Hit count: 172

Filed under:
|

The problem i am facing is that i have mapped some keys and mouse events for seraching in vim while editing a file. But those mappings impact the functionality if the quickfix buffer.

I was wondering if it is possible to map keys depending on the buffer in which they are used.

EDIT - I am adding more info for this question Let us consider a scenario. I want to map <C-F4> to close a buffer/window. Now this behavior could depend on a number of things.

If i am editing a buffer it should just close that buffer without changing the layout of the windows. I am using buffkil plugin for this.

It does not depend on extension of file but on the type of buffer. I saw in vim documentation that there are unlisted and listed buffer. So if it is listed buffer it should close using bufkill commands.

If it is not a listed buffer it should use <c-w>c command to close buffer and changing the window layout.

I am new at writing vim functions/scripts, can someone help me getting started on this

© Stack Overflow or respective owner

Related posts about vim

Related posts about gvim