Vim creating an alias for a commonly used command

Possible duplicate:
Merge command in vim

Therefore, I have to edit waf wscript files a lot. Every time I execute this command to set the file type

set filetype=python

Is there a way to set up a small alias for the above command? SO, that I can just go in EX mode and type "py", which does the same.

+5
source share
2 answers

If I understand your question correctly, the following is added to your .vimrcshoud work

autocmd BufRead,BufNewFile *.waf set filetype=python

If this is a specific file name, for example wscript, this also works:

autocmd BufRead,BufNewFile wscript set filetype=python

If you cannot rely on the extension or file name, you can add the model at the top or bottom of your file.

# vim: set filetype=python :

. :help modeline.

, , , .

+6

Ex. , .

command! Py set filetype=python

, : :Py<CR>, python.

:

nnoremap <F11> :set filetype=python<CR>
+6

All Articles