ClosestStorm / macvim

Automatically exported from code.google.com/p/macvim
0 stars 0 forks source link

Impossible to remap <D-B> for a specific filetype #411

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I'm trying to set some custom mappings to mimick the way Markdown is 
implemented in Textmate. For instance, I'd like to use the default Mac Os X 
keyboard shortcuts to format text: cmd-b for bold, cmd-i for emphasis etc.

Here is what ideally I would like to be able to do:

1. Add the following in ~/.vim/ftplugin/markdown.vim: `vmap <C-b> 
c**<C-R>"**<ESC>`
2. When opening a markdown file, cmd-b prefixes and suffixes the selection with 
"**" (bold in Markdown format).

Unfortunately, this is not possible because I need to unmap the respective menu 
item. This can only be done in `gvimrc`:

    if has("gui_macvim")
        macmenu &Tools.Make key=<nop>
        vmap <C-b> c**<C-R>"**<ESC>
    endif

That's unfortunate because this way this behavior applies to all filetypes. The 
following will not be working:

    if has("gui_macvim")
        autocmd FileType markdown call Markdow_Config()
        function Markdown_Config()
            " custom mappings go here
        endfunction
    endif

Using MacVim Custom Version 7.3 (64) on 10.7.3

Thanks!

Original issue reported on code.google.com by charlesa...@gmail.com on 4 Apr 2012 at 6:14

GoogleCodeExporter commented 9 years ago
It might work to unmap the menu item in your .gvimrc and then add the new 
mapping in ~/.vim/after/ftplugin/markdown.vim.

I admit it is a hassle.  I'm open to suggestions on how to fix this.

Original comment by bjorn.winckler@gmail.com on 16 May 2012 at 6:21

GoogleCodeExporter commented 9 years ago
It works! Thanks for this workaround. I don't know MacVim enough to provide you 
with suggestions though…

Original comment by charlesa...@gmail.com on 16 May 2012 at 10:09