在notepad++中是否有键盘快捷键来格式化代码? 我主要使用HTML, CSS和Python代码。

例如:

<title>{% block title %}    {% endblock %}</title>      
 <link rel="stylesheet" href="/media/style.css" type="text/css" media="screen" />
</head>

To:

<head>
  <title>
    {% block title %}
    {% endblock %}
  </title>
  <link rel="stylesheet" href="/media/style.css" type="text/css" media="screen" />
</head>

我记得Visual Studio用Ctrl+K+D做到了,NetBeans也有这个功能,但在notepad++中找不到它,如果它甚至可以做到的话。


当前回答

使用最新版本XMLTools的NPP+ v7.9.1无法格式化从Office 2016/2019 Word导出的VBA代码。它将所有代码放在同一行,因为它去掉了CRLF。此外,当你启用“自动验证”时,它会在第一个VBA行出错,即属性VB_Name =“VBA模块名”。因此,任何xml工具验证显然不能用于VBA验证。

其他回答

有这样一个插件UniversalIndentGUI,它可以直接从插件管理器安装,并有可能重新缩进最常用的编程语言。

如果你转到TextFX菜单,转到TextFX编辑器,你会看到一个菜单项Reindent c++ Code。

这也将格式化c#代码。

TextFX -> HTML Tidy -> Tidy: Reindent XML

在执行此操作之前,请记住选择HTML代码。

在插件>插件管理>搜索“XML工具”>安装。

该窗口将重新启动并在插件下安装XML Tools。

打开文件并单击Ctrl + Alt + Shift + B

这不是你想要的答案,但这是我有同样问题时想到的解决办法。

[更新-我现在使用vscode的一切。我认为它在很多情况下都更好。

I'm a pretty serious Notepad++ user, so don't take this the wrong way. I have started using NetBeans 8 to develop websites in addition to Notepad++ because you can set it to autoformat on save for all your languages, and there are a ton of configuration options for how the formatting looks, down to the most minute detail. You might look into it and find it is a worthy tool to use in conjunction with notepad++. It's also open source, completely free, and has a bunch of plugins and other useful things like automatically compiling Sass if you use that too. It's definitely not as quick as NP++ so it's not great for small edits, but it can be nice for a long coding session.