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, 2019 in Python by ana1504.k
• 7,890 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, 2019 by SDeb
• 13,250 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, 2019 in Python by rahul
• 360 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
• 57,640 points
0 votes
1 answer

What does the command df.describe() do for Python Pandas Dataframe?

Hi @Rajat, if you printed the output, ...READ MORE

answered May 12, 2019 in Python by Dinesh
+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, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,347 views
0 votes
0 answers
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,250 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,250 points