Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No color in vi when called from python's script

Tags:

python

vim

vi

When I edit a file with vi like :

vi .bashrc  

I have colors.

When in python's script I have :

os.system("vi .bashrc")  

I don't.

Why (I'm guessing that I open a different shell but I can't figure why the settings are different)? And how to solve this ?

I am running fedora and my shell is bash.

vi --version

gives :

VIM - Vi IMproved 7.3
like image 625
mthpvg Avatar asked Nov 30 '12 09:11

mthpvg


People also ask

How do I set no color in vi?

You can change color schemes at anytime in vi by typing colorscheme followed by a space and the name of the color scheme. For more color schemes, you can browse this library on the vim website. You can enable or disable colors by simply typing "syntax on" or "syntax off" in vi.

How do I enable Python syntax highlighting in vim?

Add the text, “syntax on” anywhere in the file to enable syntax highlighting permanently for vim editor. Save and close the file by typing ':x'. For disabling the feature, just re-open . vimrc file, change the text “syntax on” to “syntax off” and save the file.

Does VI have syntax highlighting?

Turn On or Turn Off Syntax Highlighting in VIYou can Turn On or Turn Off syntax highlighting by pressing ESC button and use command as :syntax on and :syntax off in Vi editor.

How do you add color to text in Python?

To add color and style to text, you should create a class called ANSI, and inside this class, declare the configurations about the text and color with code ANSI. Functions Used: background: allows background formatting. Accepts ANSI codes between 40 and 47, 100 and 107.


1 Answers

I suppose it's because You have alias to vim, so calling vi .bashrc from bash mean vim .bashrc

os.system has no information about your aliases, so it calls vi editor withot color-highlighting

like image 175
adray Avatar answered Sep 20 '22 04:09

adray