[英]VS Code Shortcut to remove Markup from selected text in Markdown and Latex
[英]VS Code: Shortcut to select or remove Block Comment with no text selected
我知道有注釋和取消注釋代碼塊的快捷方式( SHIFT + ALT + A ),但是有沒有一種方法可以快速 select (甚至在沒有選擇的情況下刪除)塊注釋而不使用鼠標或鍵盤到 select 並按刪除/退格鍵按鈕? 例如:
/*
This is a large block of code with at least 50 lines of code!
:
:
*/
是否有一個鍵盤快捷鍵,我可以將我的 cursor放在塊注釋中的任何位置,然后只需按幾下鍵即可將其刪除? 謝謝!
你可以設置一個宏來很容易地做到這一點。
首先,使用優秀的Select 通過擴展 (@rioV8) 到 select 之間的文本並包括塊注釋標記/*
和*/
。 將他放入您的設置中:
"selectby.regexes": {
"BlockCommentSelect": {
"backward": "\/\\*",
"forward": "\\*\/",
"forwardInclude": true,
"backwardInclude": true,
"showSelection": true
}
},
您可以將其與鍵綁定一起使用,例如:
{
"key": "alt+s", // whatever keybinding you wish
"command": "selectby.regex",
"args": ["BlockCommentSelect"],
"when": "editorTextFocus"
},
你可以在這里停下來,使用你的鍵綁定到 select 文本,然后Shift + Alt + A關閉塊注釋。
或者您可以將selectby.regex1
添加到宏中,然后一步完成選擇和切換。 這里使用宏擴展多命令將其放入您的設置以及上面的selectby.regexes
設置中:
"multiCommand.commands": [
{
"command": "multiCommand.BlockCommentOff",
"sequence": [
{
"command": "selectby.regex",
"args": ["BlockCommentSelect"]
},
"editor.action.blockComment"
]
},
]
然后是觸發該宏的鍵綁定(在您的 keybindings.json 中):
{
"key": "shift+alt+A", // trigger the macro with whatever keybinding if you wish
"command": "extension.multiCommand.execute",
"args": { "command": "multiCommand.BlockCommentOff" },
"when": "editorTextFocus && !editorHasSelection"
},
這里我使用Shift + Alt + A來觸發宏。 我使用了when
子句!editorHasSelection
,因為如果你有一個選擇,也許你只想阻止評論那個選擇(在另一個塊評論內。!)。
演示:(1)只是第一種方法,其中selectby
選擇您的文本並手動將其關閉,然后(2)使用宏版本一步完成。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.