Search code examples
webstormintellij-13

In WebStorm, how to use live templates in .txt files?


I keep a "notes.txt" file in all my WebStorm projects.

How can I use Insert Live Template (Ctrl + J), Surround With Live Template (Ctrl + Alt + J), Surround With (Ctrl + Alt + T) in a .txt file?

Also, how can I create a Live Templates Context for a particular file suffix?

For instance, in my notes.txt file, I'd like to surround The Selection with

  • [] and
  • ()

Solution

  • How can I use Insert Live Template (Ctrl + J), Surround With Live Template (Ctrl + Alt + J), Surround With (Ctrl + Alt + T) in a .txt file?

    Use Other context

    enter image description here


    Also, how can I create a Live Templates Context for a particular file suffix?

    As ordinary IDE user (via some GUI) -- no way (such functionality is absent). Only via custom plugin.


    For instance, in my notes.txt file, I'd like to surround The Selection with

    • [] and
    • ()

    You do not need Live Templates for this.

    All what you need is Settings/Preferences | Editor | General | Smart Keys --> Surround selection on typing quote or brace.

    But if you insist on using Live Templates -- use Other context (see screenshot above -- that live template does just that)