Possible Duplicate:
Aliasing a command in vim
So I have to edit waf wscript files a lot . Everytime I execute this command to set the filetype
set filetype=python
is there a way to set up an small alias for the above command ? SO that I can just go in EX mode and type "py" which does the same thing.
If I have understood correctly your question, the following added to your .vimrc
shoud work
autocmd BufRead,BufNewFile *.waf set filetype=python
If it is a particular filename like wscript
, this works too:
autocmd BufRead,BufNewFile wscript set filetype=python
If you can't rely on an extension or filename you can add a modeline at the top or bottom of your file
# vim: set filetype=python :
See :help modeline
for more information.
But it is kinda ugly because you have to modify the file, and if your are working in a team, it can be problematic.
You don't want go in Ex mode. What you want to go in is Command-line mode.
command! Py set filetype=python
Does exactly what you want: you type :Py<CR>
to change the filetype to python
.
You can also make it faster with a normal mode mapping:
nnoremap <F11> :set filetype=python<CR>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With