vscode-htmltagwrap
Wraps your selection in HTML tags. Can wrap inline selections and selections that span multiple lines (works with both single selections and multiple selections at once).
To use, select one or many chunks of code and press "Alt + W" ("Option + W" for Mac).
How to Use It
- Select one or more blocks of text or strings of text.
- Press Alt + W or Option + W for Mac.
- Type the tag name you want.
By default, pressing spacebar will deselect the closing tags, so you can add attributes to the opening tags (you can turn this feature off, see below). If nothing is selected when you run htmltagwrap, it will add an opening and closing tag at the cursor position.
NOTE: This extension works best in files that either use tabs or spaces for indentation. It may not work as well with mixed tabs/spaces.
Settings
You can change the default behavior of htmltagwrap with the following settings.
To open VS Code settings, click the "gear" icon > then "Settings"
Available settings
- htmltagwrap.tag — The default HTML tag to insert.
- htmltagwrap.autoDeselectClosingTag — Automatically deselect the closing tag after inserting a space.
Defaults
Known Issues
When using the default setting "htmltagwrap.autoDeselectClosingTag": true :
- If you undo and then redo wrapping, entering a space will not remove the selection on the closing tag as it normally would.
- After wrapping, if you press space (removes the closing tag cursor) and then backspace to the tag element name, you won’t get your closing tag cursor back.
I haven’t found good solutions to these issues using the current extension API.
Contributing
Please create an issue on GitHub if you experience a bug. I also welcome pull requests.
Как в VS Code быстро обернуть контент в тег?
Установите расширение "htmltagwrap". Выделите фрагмент текста или кода. Нажмите "Alt + W" ("Option + W" for Mac).
Всё ещё ищете ответ? Посмотрите другие вопросы с метками visual-studio-code теги emmet или задайте свой вопрос.
дизайн сайта / логотип © 2021 Stack Exchange Inc; материалы пользователей предоставляются на условиях лицензии cc by-sa. rev 2021.9.17.40238
Нажимая «Принять все файлы cookie» вы соглашаетесь, что Stack Exchange может хранить файлы cookie на вашем устройстве и раскрывать информацию в соответствии с нашей Политикой в отношении файлов cookie.
Visual Studio — как быстро обернуть текст в теги HTML?
В новом редакторе HTML в VS 2013 удален режим WYSIWYG, и панель инструментов форматирования отключена. Это хорошо, в общем, но оно также сделало простые изменения, например, сделать текст полужирным или курсивом сложнее.
Что я сейчас делаю, чтобы сделать текст полужирным шрифтом:
- Тип <b>
- VS autocompletes </b>
- Я выбираю конечный тег и нажимаю Ctrl + X
- Я иду в конец текста, который должен быть полужирным, и нажмите Ctrl + V
Это гораздо менее удобно, чем просто нажимать Ctrl + B или что-то подобное. Я знаю, что в Visual Studio есть команда «Surround with», есть настраиваемые сочетания клавиш и т.д., Поэтому я надеюсь, что функциональность Ctrl + B каким-то образом может быть достигнута в Visual Studio. Есть ли какой-нибудь умный трюк, или я, возможно, пропустил что-то другое, довольно простое?
5 ответов
Web Essentials 2013 имеет функцию Surround with tag. (Alt + Shift + W), которая более жидкая, чем встроенная Окружать с. Я, вероятно, просто буду придерживаться этого, поскольку я использую Web Essentials в любом случае.
Вы также можете добавить собственный фрагмент кода (я не знаю, почему Visual Studio не предоставил фрагмент для сильного тега по умолчанию).
Чтобы создать фрагмент:
1) Создайте текстовый файл в C:\Users\USERNAME\Documents\Visual Studio 2013\Фрагменты кода \Visual Web Developer\Мои фрагменты HTML с именем strong.snippet
2) Поместите следующий текст внутри текстового файла:
Чтобы использовать фрагмент:
1) Выберите текст
2) Щелкните правой кнопкой мыши текст и выберите «Surround With. » или нажмите Ctrl-K, Ctrl-S
3) Откройте папку «My HTML Snippets» во всплывающем меню и выберите сильный фрагмент
Создайте HTML-код-фрагмент кода в Visual Studio
1. Создайте новый .xml файл
2. Используйте следующий шаблон фрагмента:
3.. Дайте имя вашему фрагменту и сохранить-как-это, используя (YourFileName.snippet) расширение
Добавить фрагмент в Visual Studio
1. Использовать менеджер фрагментов кода: Перейти к: Инструменты/Менеджер фрагментов кода /
2. Выберите HTML из списка DropDown и откройте HTML папку DoubleClick на нем.
< ш > 4. Нажмите кнопку Импорт и просмотреть в новый файл .snippet.
Использовать свой собственный фрагмент
1. Выберите текст в Текстовом редакторе.
2. используйте комбинацию CTRL + K CTRL + X, чтобы открыть Диалоговое окно «Вставить фрагмент»
3. Выберите HTML из списка DropDown, в котором вы ранее сохранили файл .snipped
4. Выберите свой собственный фрагмент из списка. Теперь он должен обернуть ваш текст тегом </</p> , например
★ Follow the above procedure again for creating a new snippents.
HINT (just like in Sublime text editor build in feature)
You could create a Lorem Ipsum custom snippet just like this in a seconds:
HINT
Вы можете создать почти любой фрагмент кода, который вы хотите, предоставив свойство language = «», и установив правильное описание в <code> раздел
Ниже приведен пример функции JavaScript Alert()
Как обернуть текст в тег vs code
Как обернуть выделение тегом HTML в Visual Studio?
vscode-htmltagwrap
Wraps your selection in HTML tags. Can wrap inline selections and selections that span multiple lines (works with both single selections and multiple selections at once).
To use, select one or many chunks of code and press «Alt + W» («Option + W» for Mac).
How to Use It
- Select one or more blocks of text or strings of text.
- Press Alt + W or Option + W for Mac.
- Type the tag name you want.
By default, pressing spacebar will deselect the closing tags, so you can add attributes to the opening tags (you can turn this feature off, see below). If nothing is selected when you run htmltagwrap, it will add an opening and closing tag at the cursor position.
NOTE: This extension works best in files that either use tabs or spaces for indentation. It may not work as well with mixed tabs/spaces.
Settings
You can change the default behavior of htmltagwrap with the following settings.
To open VS Code settings, click the «gear» icon > then «Settings»
Available settings
- htmltagwrap.tag — The default HTML tag to insert.
- htmltagwrap.autoDeselectClosingTag — Automatically deselect the closing tag after inserting a space.
Defaults
Known Issues
When using the default setting «htmltagwrap.autoDeselectClosingTag»: true :
- If you undo and then redo wrapping, entering a space will not remove the selection on the closing tag as it normally would.
- After wrapping, if you press space (removes the closing tag cursor) and then backspace to the tag element name, you won’t get your closing tag cursor back.
I haven’t found good solutions to these issues using the current extension API.
Contributing
Please create an issue on GitHub if you experience a bug. I also welcome pull requests.