Wednesday, September 2, 2009

Re: Language dependent mapping

On Wed, Sep 2, 2009 at 6:26 AM, Dmitry V. Krivenok <krivenok@orangesystem.ru> wrote:
I want to map insertion of such strings to some key (e.g. F8).
However, I want this mapping to be language dependent.
It should recognize type of file in the current buffer and insert
appropriate string.

Is it possible to implement such mapping in VIM?
Are there ready-to-use solutions?
What should I learn to implement such mapping from scratch?

One way to do this is by using the filetype.

Create two files, $VIM/ftplugin/cpp.vim and $VIM/ftplugin/perl.vim and put your mappings in there:

in $VIM/ftplugin/cpp.vim
nmap <buffer> <F8> 80i/<esc>
imap <buffer> <F8> <esc>80i/<esc>


$VIM/ftplugin/perl.vim
nmap <buffer> <F8> 80i#<esc>
imap <buffer> <F8> <esc>80i#<esc>



--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

No comments:

Post a Comment