记事本中Python的自动缩进++
它的行为不像 Python 的 IDLE。
示例:
else:
name = 'World'
print 'Howdy', name
print 'yay'
但是在 Notepad++ 中,
else: # i press enter and this is what it does
lands me here
但是我希望能够像在 IDLE 中一样执行此操作:在 :
之后,我只需按 Enter 键即可继续。
我将文件类型设置为 Python,将格式设置为 unix。
It doesn't act like Python's 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 it like in IDLE: after the :
I can just press enter and keep on going.
I have my file type set to Python and my format to unix.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(13)
这就是您想要的:
设置>首选项>杂项。 >自动缩进(复选框)
——
有时人们会问,“我怎样才能在程序 y 中执行 x 操作?”
我梦想有一天“使用程序 z 代替”将不再是最受欢迎的回应。
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.
我在 Notepad++ 中玩了一下 python,但我遇到了选项卡问题。
因为在 python 中,缩进非常重要,但 notepad ++ 使用空格而不是制表符。
因此,要更改为选项卡,您需要进入记事本++菜单设置>;首选项...,然后选择选项卡设置,然后在选项卡设置框中选择python,并取消选中使用默认值< /strong> 并选中用空格替换。
与其他答案一样,您可能需要考虑另一种想法。
我个人使用 eclipse 和 pydev 插件以及 django plungin。
埃里克也很好。
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.
我在官方插件页面找到了Python Indent插件,效果很好!
http://docs.notepad-plus-plus.org/index.php/Plugin_Central#P< /a>
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
好吧,这是更新的答案:
Notepad++ >>插件>>插件管理器>>显示插件管理器>>找到(python缩进)点击安装>>应该下载,您需要从插件>>Python缩进>>启用再次启用
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
转到设置>首选项>语言
然后在“选项卡设置”框中选择“python”
并勾选“使用默认值”复选框。
不客气。
PS 是的,我知道这个有点旧了。我实在是忍不住了。
无论如何,这是 v7.3.2 版本。
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.
上述解决方案都不适合我,但这个有效:
安装最新版本的 notepad++(截至 2022 年 2 月)
转到设置 ->首选项->语言->选项卡设置 ->选择Python->取消选中(默认值)并确保选择“按空格替换”,计数为 4
下一步,转到“设置 ->”首选项->自动完成 ->启用自动缩进(如果尚未启用)
这应该按预期工作,因为它对我有用。
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.
在Notepad++版本v8.4.4中
自动缩进位于设置 -> 首选项 -> 自动完成
并且不再在 MISC 中。
但是,对于 Python 缩进,它对我不起作用。
有效的方法是使用 Python Indent 插件(设置为启用)。
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).
这是适用于 Notepad++ 版本 v8.1.9.3(今天最新)
在开始之前,请保存您的工作...但无需
先关闭任何打开的选项卡;安装插件 插件
>插件管理>搜索:Python 缩进 > Python 缩进(复选框)>安装>是的
Notepad++ 将重新启动...将需要 10 秒左右
第二;启用插件
插件> Python 缩进 >启用
第三个;玩得开心!
做一个测试...然后让我知道
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
之后,你应该没问题了。
After that, you should be fine.
之后重启Notepad++,就可以了。
Restart Notepad++ after, and then it works.
-- 对于较新版本,转到设置>>首选项>>自动完成>>自动缩进(复选框)
-- 对于较旧版本,转到设置>首选项>杂项。 >自动缩进(复选框)
在撰写本文时,Notepad++ 的最新版本是 v7.8.7。(已测试)
-- 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)
我发现 Notepad++ 能够胜任成为比 Notepad 更好的基本文本编辑器的任务,但它的设计并不是像适当的编程 IDE 那样智能。
也许可以让它做你所要求的事情,但我当然不知道如何设置它。
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 有 python-mode(也)可以做到这一点。抓住它,为终生享受做好准备。
Emacs has python-mode which (also) does it. Grab it and prepare for life-time enjoyment.