Home Download Buy Blog Forum Support

"subword" deletion

"subword" deletion

Postby hsoft on Thu Sep 08, 2011 8:09 pm

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?
hsoft
 
Posts: 12
Joined: Tue Feb 08, 2011 2:40 pm

Re: "subword" deletion

Postby adzenith on Fri Sep 09, 2011 4:42 pm

This frequently trips me up also.
adzenith
 
Posts: 1217
Joined: Mon Oct 19, 2009 9:12 pm

Re: "subword" deletion

Postby iamntz on Fri Sep 09, 2011 4:57 pm

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

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: Select all
[
   {
      "command": "move",
      "args": {
         "by": "subwords",
         "extend": true,
         "forward": false
      }
      
   },
   {
      "args": null,
      "command": "left_delete"
   }
]


delete_subword_forward.sublime-macro:
Code: Select all
[
   {
      "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:

Code: Select all
{ "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! :twisted:
iamntz
 
Posts: 915
Joined: Fri Apr 29, 2011 8:52 am
Location: Romania


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 22 guests