Home Download Buy Blog Forum Support

Map a command to insert a ";" at the end of line

Map a command to insert a ";" at the end of line

Postby fabricio on Wed Mar 13, 2013 1:12 pm

I'd like to map a command to insert a ; at the end of a line. Example:

Code: Select all
var fo|o:String = "bar"


The | depicts the current cursor position. Then I press a key like ctrl+; and it puts a ; at the end, like:

Code: Select all
var foo:String = "bar";


How can I do that?
fabricio
 
Posts: 6
Joined: Wed Mar 13, 2013 12:32 pm

Re: Map a command to insert a ";" at the end of line

Postby robertcollier4 on Wed Mar 13, 2013 1:20 pm

Code: Select all
self.view.insert(edit, self.view.line(self.view.sel()[0].begin()).end(), ";")
robertcollier4
 
Posts: 154
Joined: Sun Feb 24, 2013 5:37 pm

Re: Map a command to insert a ";" at the end of line

Postby fabricio on Wed Mar 13, 2013 1:23 pm

How can I bind a key to that?
fabricio
 
Posts: 6
Joined: Wed Mar 13, 2013 12:32 pm

Re: Map a command to insert a ";" at the end of line

Postby robertcollier4 on Wed Mar 13, 2013 1:41 pm

1. Tools - New Plugin
2. Add that line indented under def run
3. Change "class ExampleCommand" to "class AddSemicolonEndoflineCommand"
4. Save as add_semicolon_endofline.py to your Users directory
5. Add to your key bindings:
{ "keys": ["f5"], "command": "add_semicolon_endofline" },
robertcollier4
 
Posts: 154
Joined: Sun Feb 24, 2013 5:37 pm

Re: Map a command to insert a ";" at the end of line

Postby fabricio on Wed Mar 13, 2013 2:03 pm

Thank you.
fabricio
 
Posts: 6
Joined: Wed Mar 13, 2013 12:32 pm


Return to Technical Support

Who is online

Users browsing this forum: nonolly, Yahoo [Bot] and 11 guests