Change the mapping of F5 on the basis of specific file type

后端 未结 2 954
南笙
南笙 2021-02-10 00:33

The current mapping of my F5 key is:

imap  :w\\|!python %

Now I want that if I\'m editing any python

2条回答
  •  感情败类
    2021-02-10 00:56

    Try this:

    au BufEnter *.py map  :w\|!python %
    au BufEnter *.java imap  :w\|!javac %
    au BufEnter *.c, *.cpp imap  :w\|!make %
    

    I'm not 100% sure about the comma separated file types, trying to verify...

    The vim docs are usually pretty nasty to try to figure out how to use commands, but these should help get you started:

    :h BufEnter
    :h :autocmd
    

    Note: You may have to restart vim for these changes to overwrite the current autocommand groups.

提交回复
热议问题