Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make auto indention in nano while programming in python in linux?

Tags:

python

linux

nano

I am a beginner programmer as well as linux user. Before, I was using windows and the python IDLE was so good. I need not needed to press tab button after the "If" statement or any other loops.

Now, I am using Linux and started to write programs through the command line text editor of ubuntu called as "nano". Here, I need to press tab all the time i use "if" statement. It is very tedious. Especially when there is bunch of nested loops, it becomes difficult to remember the tabs count. And i was thinking if there was any idea to make it work like in the IDLE in windows. I also tried to google the problem but i couldn't explain it in few words. I hope you've got what my problem actually is. And i need a descent solution for this.

like image 905
Sugam Adhikari Avatar asked Mar 03 '17 16:03

Sugam Adhikari


2 Answers

Try adding the following to ~/.nanorc (you may need to create the file if it doesn't exist):

set autoindent

Note that nano is pretty lightweight editor, so it lacks a lot of features and customization that other editors provide. You might look into something like emacs or vim if you find yourself limited by your editor.

EDIT: More detail as requested:

Type nano ~/.nanorc in your terminal to open the config file with nano.
Once inside nano, type set autoindent to enable auto-indentation.
Then type Ctrl-o Ctrl-x to save the file.

like image 142
0x5453 Avatar answered Sep 20 '22 14:09

0x5453


When you run nano add -i to the command (as in nano -i).

Also you might find this useful.

like image 28
DorElias Avatar answered Sep 21 '22 14:09

DorElias