Reputation: 291
I am working in a VM
via PuTTY
.
Via terminal, I want to open, edit, and save a .py
file. How can I do it?
Thank you for your help.
Upvotes: 8
Views: 153795
Reputation: 51
Either do:
python3 -i pythonfile.py
At which you'll be entering the python editor after closing the program, or
Use a text editor like nano (since it's installed by default with most operating systems), or emacs, which also is a great terminal text editor.
nano pythonfile.py
emacs pythonfile.py -nw
(-nw is a non-gui mode)
Upvotes: 3
Reputation: 117
You also have to enter a command like i to get into insert mode. Then hit esc and :wq to save and quit. If you are using terminal often it may be helpful to have a cheat sheet
Upvotes: 4
Reputation: 781
You can simply use an editor such as vi, vim or nano:
$ vi myFile.py
Upvotes: -1
Reputation: 1006
The easiest way is to use vim
vim your_script.py
Edit your file and save it using :w or :x
You can also use emacs or nano
Upvotes: 18