首页 文章

在记事本中格式化代码

提问于
浏览
170

是否有键盘快捷键来格式化记事本中的代码?
我主要使用HTML,CSS和Python代码 .

例如:

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

至:

<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也有这个功能但是在记事本中找不到它,如果它甚至可以做到的话 .

9 回答

  • 3

    TextFX - > HTML Tidy - > Tidy:Reindent XML

    在执行此操作之前,请务必选择HTML代码 .

  • 18

    有一个 pluginUniversalIndentGUI ,它 can be installed right from the plugin manager 并且有可能重新使用最常用的编程语言 .

  • 8

    如果您转到 TextFX 菜单并转到 TextFX Edit ,您将看到一个菜单项 Reindent C++ Code .

    这也将格式化C#代码 .

  • 2

    Here is a list记事本中的可用快捷方式 .

    如果您没有所需的功能,您可以定义自己的宏并将它们分配给自定义快捷方式(我不习惯使用宏) .

    UPDATE :我会在此处发布快捷方式,以防链接失效:

    Shortcut    Command
    
    Ctrl-C  Copy
    Ctrl-X  Cut
    Ctrl-V  Paste
    Ctrl-Z  Undo
    Ctrl-Y  Redo
    Ctrl-A  Select All
    Ctrl-F  Launch Find Dialog
    Ctrl-H  Launch Find / Replace Dialog
    Ctrl-D  Duplicate Current Line
    Ctrl-L  Delete Current Line
    Ctrl-T  Switch the current line position with the previous line position
    F3  Find Next
    Shft-F3 Find Previous
    Ctrl-Shft-F Find in Files
    Ctrl-F3 Find (volatil) Next
    Ctrl-Shft-F3    Find (volatil) Previous
    Ctrl-Shft-I Incremental Search
    Ctrl-S  Save File
    Ctrl-Alt-S  Save As
    Ctrl-Shft-S Save All
    Ctrl-O  Open File
    Ctrl-N  New File
    Ctrl-F2 Toggle Bookmark
    F2  Go To Next Bookmark 
    Shft-F2 Go To Previous Bookmark
    Ctrl-G  Launch GoToLine Dialog
    Ctrl-W  Close Current Document
    Alt-Shft-Arrow keys or Alt + Left mouse click   Column Mode Select
    F5  Launch Run Dialog
    Ctrl-Space  Launch CallTip ListBox
    Alt-Space   Launch Word Completion ListBox
    Tab (selection of several lines)    Insert Tabulation or Space (Indent)
    Shft-Tab (selection of several lines)   Remove Tabulation or Space (outdent)
    Ctrl-(Keypad-/Keypad+) or Ctrl + mouse wheel butto  Zoom in (+ or up) and Zoom out (- or down)
    Ctrl-Keypad/    Restore the original size from zoom 
    F11 Toggle Full Screen Mode
    Ctrl-Tab    Next Document
    Ctrl-Shft-Tab   Previous Document
    Ctrl-Shft-Up    Move Current Line Up
    Ctrl-Shft-Down  Move Current Line Down
    Ctrl-Alt-F  Collapse the Current Level
    Ctrl-Alt-Shft-F Uncollapse the Current Level
    Alt-0   Fold All
    Alt-(1~8)   Collapse the Level (1~8)
    Alt-Shft-0  Unfold All
    Alt-Shft-(1~8)  Uncollapse the Level (1~8)
    Ctrl-BackSpace  Delete to start of word
    Ctrl-Delete Delete to end of word
    Ctrl-Shft-BackSpace Delete to start of line
    Ctrl-Shft-Delete    Delete to end of line
    Ctrl-U  Convert to lower case
    Ctrl-Shft-U Convert to UPPER CASE
    Ctrl-B  Go to matching brace
    Ctrl-Shft-R Start to record /Stop recording the macro
    Ctrl-Shft-P Play recorded macro
    Ctrl-Q  Block comment/uncomment
    Ctrl-Shft-Q Stream comment
    Ctrl-Shft-T Copy current line to clipboard
    Ctrl-P  Print
    Alt-F4  Exit
    Ctrl-I  Split Lines
    Ctrl-J  Join Lines
    Ctrl-Alt-R  Text Direction RTL
    Ctrl-Alt-L  Text Direction LT
    F1  About
    
  • 2

    最新的插件是tidy2,可以通过插件>插件管理器>显示插件管理器安装 .

    我建议编辑config 1并设置quote-marks:no,特别是如果你有使用引号的脚本 .

    此外,整理不止一次可能会导致第一次插入&符号,然后第二次更换&符号 . 您可能希望使用配置将其发送到您需要的位置 .

  • 6

    这不是你想要的答案,但这是我遇到同样问题时的解决方案 .

    我采取了错误的方式 . 我已经开始使用 NetBeans 8 来开发除记事本之外的网站,因为您可以将其设置为autoformat,保存所有语言,并且有大量配置选项可用于格式化,最简单的细节 . 您可以查看它,发现它是与记事本配合使用的有用工具 . 它绝对不如NP那么快,因此对于小编辑来说并不是很好,但对于长编码会话来说它可能会很好 .

  • 13

    For JavaScript 格式化我使用Notepad JSMin Plugin.Quite Handy

  • 119

    在我的记事本中,似乎TextFX需要一个perl环境来格式化HTML文件 . Tidy2没有任何要求,所以我觉得它更方便 .

  • 73

    如果您只需要对齐,请尝试使用名为Code Alignment的插件 .

    您可以从记事本中的内置插件管理器获取它 .

相关问题