Tuesday, October 8, 2013

Re: Filetype dependent mapping when moving between splits

On Monday, October 7, 2013 4:51:37 PM UTC+2, Gary Johnson wrote:
> On 2013-10-07, Marek Schimara wrote:
>
> > Hi all,
>
> >
>
> > I can't seem to figure out how to map the same key (let's say <F6>) to jump
>
> > between subs in Perl when looking at a Perl file, between methods in C when in
>
> > a C source file, between keywords CREATE when in SQL, etc. I can do it on
>
> > BufEnter / BufWinEnter, but these don't happen when switching between (already
>
> > open) splits.
>
>
>
> Put the key mapping for each filetype in your after/ftplugin file
>
> for each filetype:
>
>
>
> ~/.vim/after/ftplugin/perl.vim
>
> ~/.vim/after/ftplugin/c.vim
>
> ~/.vim/after/ftplugin/sql.vim
>
> etc.
>
>
>
> You could use instead a FileType autocommand in your ~/.vimrc for
>
> each of the affected filetypes.
>
>
>
> When you define each key mapping, use the <buffer> qualifier, e.g.,
>
>
>
> nnoremap <buffer> <F6> rhs-of-mapping
>
>
>
> See
>
>
>
> :help map-<buffer>
>
>
>
> Regards,
>
> Gary


Thanks, this is exactly what was needed! :-)

Marek

--
--
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/groups/opt_out.

No comments: