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,910 points
615 views

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,300 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
1,673 views
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
• 58,020 points
592 views
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 13, 2019 in Python by Dinesh
2,965 views
0 votes
2 answers
+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 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,466 views
0 votes
1 answer
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,300 points
1,468 views
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 22, 2018 in Python by SDeb
• 13,300 points
5,062 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP