Automatic indentation for Python in Notepad++
I've been googling lots and this is getting really frustrating. It doesn't act like idle.
Example:
else:
name = 'World'
print 'Howdy', name
print 'yay'开发者_高级运维
but in Notepad++
else: # i press enter and this is what it does
lands me here
But I want to be able to do like in idle: after the :
I can just press enter and keep on going. My English isn't that great.
I have my filetype set to Python etc. and my format to unix.
This is what you want:
Settings > Preferences > MISC. > Auto-Indent (checkbox)
--
Sometimes people ask, "How can I do x in program y?"
I have a dream that one day "Use program z instead" will not be the most popular response.
I played a bit with python in Notepad++ and I had a problem with the tab. Since in python your indentation is really important but notepad ++ put space instead of a tab.
So to change to tab you need to go in notepad ++ Menu Settings > Preferences... then select Tab Settings Then select python in the Tab Settings box and uncheck Use default value and check Replace by space.
Like the other answer, you might want to consider another ide. I personally use eclipse with the pydev plugin and django plungin. Erik is nice too.
I found the Python Indent plugin on the official plugin page, and it worked fine!
http://docs.notepad-plus-plus.org/index.php/Plugin_Central#P
Well, here is a updated answer:
Notepad++ >> Plugins >> plugin manager >> show plugin manager >> find (python indent) click install >> should be downloaded you need to reach to enable again from Plugins>>python indent>>enable
Go to Settings > Preferences > Language
Then on the "Tab Settings" box select "python" and tick the "Use default value" checkbox.
You're welcome.
P.S. Yeah, I know this a little old. I really just couldn't help it. Anyway, this is for version v7.3.2.
-- For Newer Versions , Goto Settings>>Preferences>>Auto-Completion>>Auto-Indent(checkbox)
-- For Older Versions , Goto Settings > Preferences > MISC. > Auto-Indent (checkbox)
By the time of this post, The newest Version of Notepad++ is v7.8.7.(tested)
- Click on Settings
- Click Preferences...
- Browse drop-down menu to find MISC.
- Tick the box which says Auto-indent
After that, you should be fine.
Restart Notepad++ after, and then it works.
This is for Notepad++ version v8.1.9.3 (the latest as of today)
Before starting this, save your work... but no need to close any open tab
First; install the plugin
Plugins > Plugins Admin > Search: Python Indent > Python Indent (check box) > Install > Yes
Notepad++ will restart... it will take 10 seconds or so
Second; enable the plugin
Plugins > Python Indent > Enable
Third; Have fun!
Do a test... and let me know
None of the above solutions worked for me but this worked:
Install latest version of notepad++ (as of Feb 2022)
Goto Settings -> Preferences -> Language -> Tab Settings -> Select Python -> Uncheck (Default Value) and make sure that the 'Replace by space' is selected with 4 as the count
Next, goto Settings -> Preferences -> Auto-Completion -> Enable Auto-Indent (if it's not already enabled)
This should work as expected as it's working for me.
In Notepad++ version v8.4.4 The Auto Indent is located in Settings->Preferences->Auto-Completion and no longer in MISC. However, for Python indentation it didn't work for me. What worked is to use the Python Indent plugin (set to Enable).
A better ide might be spyder. http://code.google.com/p/spyderlib/ its about the best IDE I have found.
Geany is a fast and light-weight cross-platform IDE, it supports auto-completion and auto-identation for python code, execute run your program , integrated console , plus has a symbol list side pannel that lets you visualize and browse you code easily, you can jump directly to function definitions and the likes using the context menu, plus it's open source
How ever for a full fledged IDE i would recommand Eric4
I've found Notepad++ to live up to the task of being a better basic text editor than Notepad, but it isn't really designed to be as smart as a proper programming IDE.
It might be possible to get it to do what you're asking for, but I certainly don't know how to set it up that way.
Emacs has python-mode which (also) does it. Grab it and prepare for life-time enjoyment.
精彩评论