Sublime Forum

"subword" deletion

#1

I’m transitioning from Textmate to ST and I’m slowly getting used to it and customizing it to my liking, but I still have a significant pain point that I haven’t been able to fix yet: subword deletion.

In Textmate, holding alt puts in in “word” mode meaning that movements and deletion will be made by words. Holding ctrl puts you in “subwords” mode, which are like words, but they stop at stuff like “subword1_subword2” or “subword1Subword2”.

ST already support subword movement, but whenever I press Ctrl+(del|backspace), I get bitten because the whole word is deleted instead of the subword. Any way to fix this?

1 Like

#2

This frequently trips me up also.

1 Like

#3

Ok, let me tell you how i fix this.
First, i recorded a macro. Then… I save it :astonished:

Ok, without being an ass, here are two macros: one to delete backward, one to delete forward (alt+backspace & alt+delete):
delete_subword.sublime-macro:

[code]
{
“command”: “move”,
“args”: {
“by”: “subwords”,
“extend”: true,
“forward”: false
}

},
{
	"args": null,
	"command": "left_delete"
}

][/code]

delete_subword_forward.sublime-macro:


	{
		"command": "move",
		"args": {
			"by": "subwords",
			"extend": true,
			"forward": true
		}
	},
	{
		"args": null,
		"command": "right_delete"
	}
]

Save it into your User directory. Now, you bind keys like this:

{ "keys": "alt+backspace"], "command": "run_macro_file", "args": {"file": "Packages/User/delete_subword.sublime-macro"} }, { "keys": "alt+delete"], "command": "run_macro_file", "args": {"file": "Packages/User/delete_subword_forward.sublime-macro"} },

Next: you start coding some real shits and leave the damn forum alone! :smiling_imp:

1 Like

#4

I think the syntax changed a little since 2011. I just used this on build 3153 and worked fine using this:

User.sublime-keymap

	{ "keys": ["alt+backspace"], "command": "run_macro_file", "args": {"file": "Packages/User/delete_subword.sublime-macro"} },
	{ "keys": ["alt+delete"], "command": "run_macro_file", "args": {"file": "Packages/User/delete_subword_forward.sublime-macro"} },

delete_subword.sublime-macro

[
    {
        "command": "move",
        "args": 
        {
            "by": "subwords",
            "extend": true,
            "forward": false
        }
    },
    {
        "args": {},
        "command": "left_delete"
    }
]

delete_subword_forward.sublime-macro

[
    {
        "command": "move",
        "args": 
        {
            "by": "subwords",
            "extend": true,
            "forward": true
        }
    },
    {
        "args": {},
        "command": "right_delete"
    }
]
1 Like

#5

Opening square brackets weren’t properly migrated when the forum software was changed from phpbb to discourse.

1 Like