Skip to content
This repository has been archived by the owner on May 23, 2021. It is now read-only.

Commit

Permalink
Create custom-surround.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jugmac00 committed Aug 11, 2020
1 parent b3b9f44 commit b086794
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions vs_code/custom-surround.md
@@ -0,0 +1,20 @@
# How do you surround marked text with a custom snippet?

In order to mark strings as "translatable" in Flask via Flask-WTF, you need to apply special syntax.

This means, e.g. in a Jinja template a string like `Conference` has to be transformed into `{{ _('Conference') }}`.

This is a very tedious work, so I created a shortcut for it.

Add the following lines to your `keybindings.json`:

"key": "ctrl+shift+alt+0",
"command": "editor.action.insertSnippet",
"when": "editorHasSelection || editorHasMultipleSelections",
"args": {
"snippet": "{{ _('${TM_SELECTED_TEXT}') }}"
}

I used "ctrl+shift+alt+0" as on the German keyboard the closing curly brace is on the same key as the `0`.

via https://stackoverflow.com/a/53545200/672833

0 comments on commit b086794

Please sign in to comment.