I'm trying to wrap bunch of data with following tags.
For an example:
link1
link2
link3
link4
link5
I want each one of them to be wrapped with following tags.
<url>
<loc>link1</loc>
<lastmod>2020-01-16T22:59:45+00:00</lastmod>
<priority>0.80</priority>
</url>
<url>
<loc>link2</loc>
<lastmod>2020-01-16T22:59:45+00:00</lastmod>
<priority>0.80</priority>
</url>
....
I want to know if this is possible to do using Emmet code. Any help would be appreciated.
Another alternative is to use regular snippets. This is for vscode:
"link snippet": {
"prefix": "link",
"body": [
"<url>"
"<loc>$TM_SELECTED_TEXT</loc>",
"<lastmod>2020-01-16T22:59:45+00:00</lastmod>", // if date is fixed ahead of time
// use below if date is dynamic at creation time
"<lastmod>${CURRENT_YEAR}-${CURRENT_MONTH}-${CURRENT_DATE}T${CURRENT_HOUR}:${CURRENT_MINUTE}:${CURRENT_SECOND}+00:00</lastmod>"
"<priority>0.80</priority>",
"</url>",
""
],
"description": "Wrap link with url, etc."
},
Then, because you will need to chain 3 commands together to make this easy, use a macro extension like multi-command. Pu this into your settings.json:
"multiCommand.commands": [
{
"command": "multiCommand.expandLink",
"sequence": [
"editor.action.insertCursorAtEndOfEachLineSelected",
"cursorHomeSelect",
{
"command": "editor.action.insertSnippet",
"args": {
"name": "link snippet",
}
},
]
}
]
That will trigger the snippet after it selects each of your lines separately. To trigger the macro itself you need a keybinding (in keybindings.json):
{
"key": "shift+alt+l",
"command": "extension.multiCommand.execute",
"args": { "command": "multiCommand.expandLink" },
},
A fair amount of setup, but then it is just the one keybinding to trigger it all. Demo: