vim creating alias for frequently used command

0 votes
I want edit waf wscript files. I am executing the following command to set the filetype:

set filetype=python

Is there any other 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 thing? Can anyone tell me the solution?
May 14 in Python by ana1504.k
• 7,870 points

1 answer to this question.

0 votes
You can add the following to your .vimrc and try:

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 such as:

# vim: set filetype=python :
answered May 14 by SDeb
• 13,160 points

Related Questions In Python

0 votes
3 answers

What is the python keyword “with” used for?

The with statement in Python simplifies exception ...READ MORE

answered Jul 19 in Python by rahul
• 200 points
0 votes
1 answer

What is set() function used for?

Sets are unordered, as you say. Even ...READ MORE

answered Oct 17, 2018 in Python by Priyaj
• 56,520 points
0 votes
1 answer
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 232 views
0 votes
1 answer

Which IDE can be used for Python on Mac OS X

Have tried many different (Kate, Eclipse, Scite, ...READ MORE

answered Oct 15, 2018 in Python by SDeb
• 13,160 points
0 votes
1 answer

Return a list inside a for loop while iterating over the elements of another list

The print() is getting called multiple times ...READ MORE

answered Sep 21, 2018 in Python by SDeb
• 13,160 points