Login or Register to Ask a Question and Join Our Community

Vim: different mappings for different window

Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Vim: different mappings for different window
# 1  
Old 06-07-2010
Vim: different mappings for different window

My .vimrc file has filetype mappings for different filetypes such as :

autocmd FileType sh map gf ...
autocmd FileType ruby map gf ...

While rewriting a program from one language to another, I have 2 splits, one with shell and one with ruby. I would assume that "gf" would take on its mapping based on filetype. However, it can only hold one mapping at a time.

Is there any way to declare a mapping only for the existing buffer. I tried ":windo" and ":bufdo" but they work for all windows or buffers.
# 2  
Old 06-08-2010
I couldn't find a way to have two mappings, so I tried a variation on this:
My examples

Several files each with separate mappings (c pc sql sh s) plus a basic .vimrc.

When I move between buffers I push an F key to reset the mappings. It's clunky but it works.
This User Gave Thanks to jim mcnamara For This Post:
# 3  
Old 06-09-2010
Originally Posted by jim mcnamara

When I move between buffers I push an F key to reset the mappings. It's clunky but it works.
Perhaps, my key combinations could map to a function in vim, that checks the filetype at runtime and then executes the code. Haven't done any plugin writing, but I guess I could try this out a little later if no other answer comes up.

---------- Post updated 06-09-10 at 10:30 AM ---------- Previous update was 06-08-10 at 07:41 PM ----------

I have found the answer.

:help map-local

for example:

:map <buffer> ,w /[.,;]<CR>

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Toggle between xterm window and standard terminal window

Is it possible to toggle back and forth between an xterm invoked from one tty, and a shell invoked from a different tty? I am running Centos 7 with KDE and booting in non-graphic mode. After logging in on the default window (/dev/tty1) , I can then use ALT-F2 to access a new window (/dev/tty2),... (1 Reply)
Discussion started by: rhgscty
1 Replies

2. UNIX for Advanced & Expert Users

Vim :f

Can someone please tell me what this does? :f word I thought that was the way to save files with a different name but after a quick google search I saw it was like this. :w filename (4 Replies)
Discussion started by: cokedude
4 Replies

3. UNIX for Advanced & Expert Users

GID mappings cached?

We had a mapping to one UNIX box just fine, the server was changed to another UNIX box and now when mapping drives from Windows box to new UNIX box, we get the old GID associated with our Windows user. When checking on new UNIX box, we see GID of 108, which is what we want, but when we map the... (0 Replies)
Discussion started by: bd4021
0 Replies

4. Solaris

Very Importan - Vim Settings - Error while opening a File using vim

I downloaded vim.7.2 and compiled the vim source . Added the vim binary path to PATH (Because iam not the root of the box) when i load the file using vim it throws me an error Error detected while processing /home2/e3003091/.vimrc: line 2: E185: Cannot find color scheme darkblue line... (0 Replies)
Discussion started by: girija
0 Replies

5. Red Hat

Maximizing X window without Window Switcher

Hi everyone! I have a strange situation. I'm running an NX remote Gnome desktop session. On the remote machine, there is a whole load of unsaved data in a window. A problem that I've been having with this NX session is that I can't load Gnome Applets, including the Window Switcher. So.. when I... (0 Replies)
Discussion started by: alexandicity
0 Replies

6. UNIX for Advanced & Expert Users


Does anyone know the fast way to go to tab/2 distance in vim. I mean set four spaces. (1 Reply)
Discussion started by: mirusnet
1 Replies

7. UNIX and Linux Applications

Help with Vim

How do I use compilers and syntax highlighting in (g)Vim? Specifically, I need a Common Lisp compiler and a C++ compiler. Thanks in advance! (Note: Disregard my other topic.) (1 Reply)
Discussion started by: led3234
1 Replies

8. UNIX for Dummies Questions & Answers

Need some help with vim

I use vim for writing code. I was using nano but found that vim is a much advanced editor. I am trying to achieve something like this: When trying a loop or a function, I generally type: function name() {} Now when I take my cursor one position to the left and press the return key, it give... (4 Replies)
Discussion started by: Legend986
4 Replies

9. Solaris

Vim 7.0

I want to install VIM 7.0 from sunfreeware.com onto a server. The security guys are giving me a hard time because they found this security vulnerability. http://xforce.iss.net/xforce/xfdb/6259 This vulnerability came out in 2001, and it looks like it was mostly for linux, but I cant be... (1 Reply)
Discussion started by: BG_JrAdmin
1 Replies

10. Windows & DOS: Issues & Discussions

window 2000 professional not pinging my window 98 system.

Hello, We someone help me resolve this problem. I have window 2000 professional, windows 98 and Unixware 7.0.1 on the network. I was able to establish connection with all. However, l was unable to ping window 98 from window 2000 professional. I was able to ping the window 2000 from the window... (10 Replies)
Discussion started by: kayode
10 Replies
Login or Register to Ask a Question

Featured Tech Videos