如何在Visual Studio中用HTML标记包装选择? [英] How do I wrap a selection with an HTML tag in Visual Studio?

查看:155
本文介绍了如何在Visual Studio中用HTML标记包装选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这似乎是世界上最基本的问题,但是如果我能找到答案,那该死的.

This seems like the most basic question in the world, but damned if I can find an answer.

是否存在Visual Studio固有的或通过Code Rush或其他第三方插件提供的键盘快捷方式,可以用HTML标记包装当前选择内容?我已经厌倦了键入开始标记,将放错位置的结束标记剪切到剪贴板,移动光标并将其粘贴到它所属的末尾.

Is there a keyboard shortcut, either native to Visual Studio or through Code Rush or other third-party plug-in, to wrap the current selection with an HTML tag? I'm tired of typing the opening tag, cutting the misplaced closing tag to the clipboard, moving the cursor, and pasting it at the end where it belongs.

更新:这是TextMate如何处理带有标签的选择 .坦白说,我很惊讶Visual Studio似乎没有类似的功能.为我可能想使用的每个可能的标签创建宏或代码段似乎很荒谬.

Update: This is how TextMate handles surrounding a selection with a tag. Frankly, I'm stunned that Visual Studio doesn't seem to have a similar feature. Creating a macro or snippet for every conceivable tag I might want to use seems absurd.

推荐答案

Visual Studio 2015附带了一个新的快捷键Shift + Alt + W,该快捷键用div包裹了当前选择.该快捷方式将文本"div"留在屏幕上.选择,使其可以无缝更改为任何所需的标签.加上自动结束标签更换,可以快速解决问题.

Visual Studio 2015 comes with a new shortcut, Shift+Alt+W, that wraps the current selection with a div. This shortcut leaves the text "div" selected, making it seamlessly changeable to any desired tag. This coupled with the automatic end tag replacement makes for a quick solution.

此快捷方式在Visual Studio 2017中也可用,但是您必须具有"ASP.NET和Web开发"工作负载已安装.

This shortcut is available in Visual Studio 2017 as well, but you must have the "ASP.NET and Web Development" workload installed.

Shift+Alt+W > p > Enter

这篇关于如何在Visual Studio中用HTML标记包装选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆