Notepad ++ автоматический отступ HTML-кода при написании

20986
Mark Skelton

Я видел много плагинов в Notepad ++ для отступа HTML-кода после написания кода, но есть ли плагин или другой метод для автоматического определения HTML -кода во время написания кода? Многие другие языки программирования Notepad ++ поддерживают автоматический отступ, когда вы пишете, но html, похоже, не имеет такой же поддержки.

Есть идеи?

1
Я использую [плагин TextFX] (http://textfx.no-ip.com/textfx/), в который встроен HTML Tidy. DavidPostill 8 лет назад 0
[Плагин автоматического отступа для Notepad ++] (http://softwarerecs.stackexchange.com/a/1504) DavidPostill 8 лет назад 1
Какой вариант вы выбрали? DavidPostill 8 лет назад 0
Я пошел на отступ за плагином. Mark Skelton 8 лет назад 0

2 ответа на вопрос

5
DavidPostill

Is there a plugin or other method to auto intent HTML while you are writing the code?

Two possibilities:

  1. Use the TextFX plugin which has HTML Tidy built in.

  2. Use the Indent by fold plugin (see below).


IndentByFold plug-in for Notepad++

enter image description here

Here's your php code indented by fold:

enter image description here

(The image above is not assembled from two separate images! Notepad++ has the ability to clone its tabs in a new view)

You can access here a screencast demo for the Indent by fold plugin. There's no separate plugin for the auto complete feature in the video; for most languages there are defined already xml files with keywords:

enter image description here

Now, about the Code Alignment plugin: just use it only if you are not satisfied with the Indent by fold results!


Here's how you can define a shortcut for the the indent operation:

Settings/Shortcut mapper/Plugin Commands

enter image description here

The Ctr + K and Ctrl + D shortcuts key are already "taken" (by comment code and duplicate selection), therefore I've choosed another combination. But everyone can re-map all the commands according to own needs.


If anytime you find a language with a "weak" code formatting / folding you can take the lead, and proceed in defining your own folding and coloring rules for keywords, comments, numbers, operators and delimiters:

enter image description here

See how beautiful Indent by fold works when I press ALt + K ?

The vbproc keyword is underlined because the DSpellChecker plugin is active.

Here are a zillion UDLs (User Defined Languages) for Notepad++. To better understand how to use this feature I recommend you to read the UDL 2.0 online documentation. It was a time when folding was possible only for single words like "BeginSub" and "EndSub". Now it is easier because folding can be done using expressions, as you can see in my My better ASP example. Even now, the UDL cannot address every imaginable situations (there is a work in progress called UDL 3). But can we blame the Notepad++ developers for not achieving perfection with this free and simple, yet wonderful utility?

Source answer Auto indentation plugin for Notepad++ by Sorin Călinică

Хотя это был ответ для автора, он явно спрашивает во время записи. Это не соответствует этому требованию. У меня те же требования и я хочу авто отступ при написании, как это делается для PHP. Я не хочу нажимать горячую клавишу для этого каждый раз. Есть ли новое современное решение? Bob 6 лет назад 0
@ Боб Не то, что я знаю. DavidPostill 6 лет назад 0
1
E.Arrowood

I don't know of something that is for Notepad++, but I strongly recommend downloading Brackets and then getting the Emmet and Beautify extensions. Emmet contains tons of great keystrokes for quickly creating html elements, and Beautify has an awesome keystroke that can auto-indent an entire page (my key binding is ctrl+shift+L, which I think is the default).