Loading ...
Sorry, an error occurred while loading the content.

Re: File extension vim script

Expand Messages
  • Tony Mechelynck
    ... What you want is buffer-local mappings specific to the file _type_. Add between the {lhs} and {rhs} of your mappings above, and move them to: (on
    Message 1 of 4 , Oct 29, 2007
    • 0 Attachment
      Ricardo Carvalho wrote:
      > I have the following section in my .vimrc:
      >
      > map <F5> :w<cr>:!gcc % -Wall -pedantic -O2 -ansi -g -o %<<cr>
      > map <F6> :!./%<<cr>
      > map <F7> :!gdb %<<cr>
      > map <F8> :!valgrind %<<cr>
      >
      > It's obvious that some key bindings are unnecessary when editing non c
      > source files.
      > Is there a way to use conditionals key bindings based on the extension
      > of the file that I want to edit?
      >
      > I know, my english is poor. Sorry.

      What you want is buffer-local mappings specific to the file _type_.

      Add <buffer> between the {lhs} and {rhs} of your mappings above, and move them to:

      (on Windows, but in Vim notation) $HOME/vimfiles/after/ftplugin/c.vim
      (on Unix) $HOME/.vim/after/ftplugin/c.vim

      (create the file and subdirectories if they don't exist).

      Then you can use other settings for other filetypes. Be sure to always use
      ":setlocal" (not :set) and :map <buffer> (not global mappings) so the settings
      for one filetype won't interfere with those for another.


      Best regards,
      Tony.
      --
      Truthful, adj.:
      Dumb and illiterate.
      -- Ambrose Bierce, "The Devil's Dictionary"

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    Your message has been successfully submitted and would be delivered to recipients shortly.