如何在记事本中添加用户定义的折叠区域++?

发布于 2024-09-24 00:51:34 字数 413 浏览 5 评论 0原文

我不知道如何配置 Notepad++ 以显示用户定义的关键字的区域。

我有一个很大的跟踪文件,它显示了过程的开始和结束。该文件看起来像这样:

Beginn abc.def;
   ...
   Beginn ghi.jkl;
   ...
   Ende ghi.jkl;
   ...
Ende abc.def;

我想像这样折叠这些区域:

[+] Beginn abc.def;

或者

[-] Beginn abc.def;
       ...
[+]    Beginn ghi.jkl;
       ...
    Ende abc.def;

是否可以配置 Notepad++ 以显示这样的折叠?

I can't figure out how to configure Notepad++ to display regions for user defined keywords.

I have a big trace file which shows the start and the end of a procedure. The file looks like this:

Beginn abc.def;
   ...
   Beginn ghi.jkl;
   ...
   Ende ghi.jkl;
   ...
Ende abc.def;

I would like to fold those regions like this:

[+] Beginn abc.def;

or

[-] Beginn abc.def;
       ...
[+]    Beginn ghi.jkl;
       ...
    Ende abc.def;

Is it possible to configure Notepad++ to display folding like this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

瘫痪情歌 2024-10-01 00:51:34

对于 6.5.5 及更高版本:

在“语言”菜单下,有一个名为“定义您的语言...”的菜单项

在此处输入图像描述

在“文件夹和默认”选项卡中,有一个名为“代码折叠”的组,您可以在其中输入“打开”和“关闭”关键字。

折叠代码

对于 6.5.5 之前的版本:

在“查看”菜单下有一个名为“用户定义的对话框...”的菜单项。 "

查看定义您的语言

在“文件夹和默认”选项卡中,您可以输入“文件夹打开关键字” ”和“文件夹关闭关键字”

文件夹打开关闭关键字

For version 6.5.5 and above:

Under the menu "Language" there is a menuitem called "Define your language..."

enter image description here

In the tab "Folder & Default" is a group called "Folding in code" where you can enter an "Open"- and a "Close"-Keyword.

Folding in code

For versions older than 6.5.5:

Under the menu "View" there is a menuitem called "User-Defined Dialog..."

View Define your language

In the tab "Folder & Default" you can enter a "Folder Open Keyword" and a "Folder Close Keyword"

Folder Open Close Keyword

软糯酥胸 2024-10-01 00:51:34

另一种简单的方法是添加“注释命令”,然后添加“ { ”以开始,然后添加“注释命令”,然后添加“ } ”。在 C/C++、Java、Javascript 等中,它就像这样:

// {

// }

Another simple way is just add "comment command" and then " { " to begin and later "comment command" and then " } ". In C/C++, Java, Javascript, etc. it would be just like this :

// {

// }
烟酒忠诚 2024-10-01 00:51:34

我有类似的问题。我想添加像 #region / #endregion 这样的自定义标签,以在不支持它的语言中创建任意折叠点。具体来说,我正在尝试为 php 执行此操作。

研究了一两个小时后,由于底层的 scintilla 词法分析器,修改现有语言似乎相当困难,编写插件可能是完成此任务的唯一方法。

然而,我确实发现了一个不错的解决方法:

将您想要折叠的代码包装在注释中,例如:

#{ 
...
#}

然后将光标移到左大括号之前,然后按 CTRL+ALT+ b 突出显示整个块,然后按 ALT+h 将其隐藏。

这是与折叠不同的操作,但它可以在紧要关头发挥作用。

I have a similar problem. I want to add a custom tag like #region / #endregion to create arbitrary folding points in languages that don't support it. Specifically, I am trying to do this for php.

After researching for an hour or two, it seems that modifying an existing language is quite difficult due to the underlying scintilla lexer, and writing a plugin may be the only way to accomplish this.

I did discover however a decent workaround:

Wrap the code you wish to fold in comments like:

#{ 
...
#}

Then move your cursor before the open brace and press CTRL+ALT+b to highlight the entire block, followed by ALT+h to hide it.

It's a different operation than folding, but it works in a pinch.

扬花落满肩 2024-10-01 00:51:34

我使用 Marcelo 的答案为自己解决了这个问题(在 Perl 中),做了一个更改......
如果我在注释符号和括号之间包含一个空格,那么它就不起作用。它必须立即放置在:

#START example
################{

print "Hi there! ";
print "How are you?\n";

#}END example

请注意,如果我这样做:

#END example }

在文本后面加上括号,它也不起作用

I used Marcelo's answer to solve this for myself (in Perl), with one change...
If I included a space between the comment symbol and the bracket then it wouldn't work. It had to be placed immediately after:

#START example
################{

print "Hi there! ";
print "How are you?\n";

#}END example

Note that if I do:

#END example }

with the bracket after the text it won't work either

昇り龍 2024-10-01 00:51:34

!!免责声明:PHP 完全菜鸟!

假设您将 PHP 封装在某些 HTML 中,则可以使用 ?> 定义自定义部分。

例如:

<html>
<head></head>
<body>
<?php 
$cities[1] = "Phoenix";$cities[2] = "Tucson";$cities[3] = "Flagstaff";  
$capitals['CA'] = "Sacramento";$capitals['TX'] = "Austin";$capitals['OR'] = "Salem";    
$cities[] = "Phoenix";$cities[] = "Tucson";$cities[] = "Flagstaff"; 
echo "Here are cities: $cities[1]";echo nl2br("\n");
?>
</br>
<?php
$cities = array( "Phoenix","Tucson","Flagstaff");   
$capitals = array( "CA" => "Sacramento","TX" => "Austin","OR" => "Salem",);
echo $capitals['TX'];echo nl2br("\n");  
?>
<body>
</html>

Notepad++ 将允许您任意折叠这些部分,并且您可以用“#”标记这些部分。
刚刚学习 PHP,所以我的代码可能不太好;这仍然是一个持续的过程。

!! Disclaimer: Total noob at PHP !!

Assuming that you are wrapping your PHP in some HTML, you can define custom sections using <?php and?>.

Ex:

<html>
<head></head>
<body>
<?php 
$cities[1] = "Phoenix";$cities[2] = "Tucson";$cities[3] = "Flagstaff";  
$capitals['CA'] = "Sacramento";$capitals['TX'] = "Austin";$capitals['OR'] = "Salem";    
$cities[] = "Phoenix";$cities[] = "Tucson";$cities[] = "Flagstaff"; 
echo "Here are cities: $cities[1]";echo nl2br("\n");
?>
</br>
<?php
$cities = array( "Phoenix","Tucson","Flagstaff");   
$capitals = array( "CA" => "Sacramento","TX" => "Austin","OR" => "Salem",);
echo $capitals['TX'];echo nl2br("\n");  
?>
<body>
</html>

Notepad++ will then allow you to collapse the sections arbitrarily and you can label the sections with "#".
Just learning PHP, so my code might not be awesome; It's still an ongoing process.

偏爱自由 2024-10-01 00:51:34

如果是 SQL,那么用 BE​​GIN 和 END 封装代码效果很好。将显示 BEGIN 语句以及您在同一行添加的任何注释。

例如:

BEGIN --creating temp table with eligible users

   ...code

END

If it's SQL, then encapsulating your code with BEGIN and END works well. The BEGIN statement is shown, plus any comments you add on the same line.

e.g:

BEGIN --creating temp table with eligible users

   ...code

END
北渚 2024-10-01 00:51:34

第一步:添加具有打开和关闭功能的唯一键(即,

#1
{{{
#2
{{{
#2
}}}
##
}}}

使用缩进/或注释来指示嵌套级别。

步骤 2:完成后,{CTRL}-H 替换所有“{{{”和“}}}”。

第 3 步:评论条(应用程序)。

STEP ONE: Add a unique key with open and close (i.e.,

#1
{{{
#2
{{{
#2
}}}
##
}}}

Use indentation and/or comments to indicate nest-level.

Step 2: {CTRL}-H when you're finished. Replace all '{{{' and '}}}'.

STEP 3: Comment strip (app).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文