Thursday, June 12, 2014

Re: Mapping only in specific buffer

Hi Gary,

In fact I have in mind the mapping <F3> known on Windows OS used to search forward or backward in registry or in visual studio environnment.

I would like to used only this keystroke to search previous or next occurence:
1/ in a diff buffer : a difference
2/ in a normal buffer : the last searched pattern
3/ .... etC...


On Thursday, June 12, 2014 6:27:31 PM UTC+2, Gary Johnson wrote:
> On 2014-06-12, Ni Va wrote:
>
> > Hi,
>
> >
>
> >
>
> > I would like to map ]c diff jump only in a vim buffer.
>
> >
>
> > I have done this for the moment but would like to make conditional
>
> > test on &diff var :
>
> > map <F2> : norm ]c<CR>
>
>
>
> If you're mapping a key to be pressed in normal mode, you don't need
>
> to go into ex mode and use :normal--just map the command directly.
>
>
>
> map <F2> ]c
>
>
>
> To make a mapping apply only in a particular buffer, use the
>
> <buffer> modifier.
>
>
>
> map <buffer> <F2> ]c
>
>
>
> See
>
>
>
> :help :map-<buffer>
>
>
>
> That :map command has to be executed in the buffer in which you want
>
> it to apply. If you want it to apply to buffers of a certain file
>
> type, you can put the command in a file in your
>
> ~/.vim/after/ftplugin directory. See
>
>
>
> :help ftplugin-overrule
>
>
>
> Or, you can put a FileType autocommand in your ~/.vimrc like this
>
> example that assumes you want the mapping to be defined only for the
>
> c file type.
>
>
>
> au FileType c map <buffer> <F2> ]c
>
>
>
> You can make mapping conditional on option settings such as 'diff',
>
> but how you do that depends on the behavior you're really trying to
>
> achieve and when you want the mapping to depend on 'diff': when the
>
> mapping is defined or when <F2> is pressed.
>
>
>
> 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

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

No comments: