简体   繁体   English

使用Python的Notepad ++ Folding Lines

[英]Notepad++ Folding Lines using Python

I'm using Notepad++ to write Python 2.7 code. 我正在使用Notepad ++编写Python 2.7代码。 I just want to create my own block indicator and fold the block so it is hidden. 我只想创建自己的块指示器并折叠块以使其隐藏。 Something like: 就像是:

#//begin
#//end

I'm going to use the comment # as the front character so as not to upset the code. 我将使用注释#作为前面的字符,以免扰乱代码。 All the questions and answers I've found on this topic are several years old back when Notepad++ seemed to allow this. 在Notepad ++似乎允许的情况下,我在这个主题上找到的所有问题和答案都已有几年了。 Now the menus have changed and it doesn't seem possible to simply do this. 现在菜单已经改变了,似乎不能简单地做到这一点。 There is the option to create a "User defined language" but I don't want to do this from scratch. 可以选择创建“用户定义的语言”,但我不想从头开始。 I want to add this one feature to Python. 我想将这一功能添加到Python中。 Or, if it is simple enough, create my own language using Python defaults as a starting point and adding this one feature. 或者,如果它足够简单,使用Python默认值作为起点创建我自己的语言并添加这一功能。 I just can't figure out how. 我只是无法弄清楚如何。

Adding a user defined language using Notepad++ to just add folding can be done as follows: 使用Notepad ++添加用户定义的语言以添加折叠可以按如下方式完成:

  1. Click on Language > Define your language 单击Language > Define your language

  2. Click on Create New... and enter a name for it eg Twegner 单击Create New...并输入它的名称,例如Twegner

  3. In the section on the right add your #//begin and #//end styles for Open and Close . 在右侧的部分中,为OpenClose添加#//begin#//end样式。

  4. Close the dialog and create a file using your styles. 关闭对话框并使用样式创建文件。

  5. Select Language > Twegner (which should now be shown at the bottom of the menu). 选择Language > Twegner (现在应该显示在菜单的底部)。

For example: 例如:

Notepadd ++用户定义语言截图

This would then work as follows: 这将按如下方式工作:

折叠的例子

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM