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


当前回答

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

其他回答

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

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

这也将格式化c#代码。

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

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

如果你所需要的只是对齐,可以试试名为Code alignment的插件。

你可以从notepad++中的内置插件管理器中获取它。

TextFX -> HTML Tidy -> Tidy: Reindent XML

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