I doubt you can do what you want in one step, without running some code. But you can do it with a macro so you can have multiple steps fired at once. In this example I am using the macro extension multi-command, but there are other macro extensions out there.
In your settings.json:
"multiCommand.commands": [
{
"command": "multiCommand.commentSection",
// "interval": 750, // you don't need this, just for illustration
"sequence": [
"cursorEnd",
{
"command": "type", // add 75 -'s'
"args": {
"text": " ---------------------------------------------------------------------------"
}
},
"editor.action.addCommentLine",
// select this wrapped line so the next snippet can use TM_SELECTED_TEXT
"cursorHomeSelect",
"cursorHomeSelect",
{
"command": "editor.action.insertSnippet", // trim to first 80 characters
"args": {
"snippet": "${TM_SELECTED_TEXT/(.{80}).*/$1/g}",
}
}
]
}
],
And then whatever keybinding you choose in keybindings.json
{
"key": "ctrl+alt+-",
"command": "extension.multiCommand.execute",
"args": { "command": "multiCommand.commentSection" }
},
The basic idea is to add too many hyphens - say 75 - and then select the entire wrapped line and keep only the first 80 characters, thus trimming the trailing hyphens to fill out to 80 total characters on the line.
It works on blank lines too as the end of the demo demonstrates.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…