在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++中找不到它,如果它甚至可以做到的话。


当前回答

不。notepad++不能自己格式化。格式化可以在许多ide中轻松完成,如Eclipse, NetBeans, Visual Studio [Code]。

其他回答

我们可以在最新版本的notepad++中使用以下快捷方式来格式化代码

Alt + Ctrl + Shift + B

答:截至2019年6月

从插件管理安装XML Tools插件(至少在notepad++ 7.7中)

然后点击插件-> XML工具->漂亮打印(仅XML与换行)

这对我很有帮助。

TextFX -> HTML Tidy -> Tidy: Reindent XML

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

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

[更新-我现在使用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.

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

这也将格式化c#代码。