Sublime Forum

CTRL+] doesn't work properly on ST4

#1

@bschaaf From your answer ( https://forum.sublimetext.com/t/difference-between-tap-and-ctrl/65599/2?u=yenivov911 ), you said that CTRL+] will always indent but it’s not the case I’m afraid.

When I press CTRL+] on a line that doesn’t include any character, it will not indent. But tab does.

Only when I add a character ( even a space or symbol ) then it only indents.

So I’m not sure if I misunderstood your words from the answer or if your explanation is not accurate or if it’s a bug on ST4.

0 Likes

#2

It behaves always like that, add following keybinding should “fix” your case.

{
    "keys": ["ctrl+]"],
    "command": "insert",
    "args": {"characters":"\t"},
    "context": [
        { "key": "preceding_text", "operator": "regex_match", "operand": "^$", "match_all": true },
        { "key": "following_text", "operator": "regex_match", "operand": "^$", "match_all": true },
    ],
},

but it only works with a single line. Otherwise, I am afraid that you’d have to implement your own “indent” command.

import sublime
import sublime_plugin


class AlwaysIndentCommand(sublime_plugin.TextCommand):
    def run(self, edit: sublime.Edit) -> None:
        for sel in reversed(self.view.sel()):
            for line in reversed(self.view.lines(sel)):
                self.view.insert(edit, line.begin(), "\t")
1 Like

#3

I think tab is even better? LOL

tab will not always indent but is more convenient and indent most o the time than CTRL+] which will always indent according to bschaaf’s answer😂

0 Likes