Home Download Buy Blog Forum Support

Execute a command and go back to a given position in the tex

Execute a command and go back to a given position in the tex

Postby gustavo.ggutierrez on Tue Jan 21, 2014 9:44 pm

I am new to Sublime Text internals. I am trying to get a command executed while keeping the cursor position. I am in the following scenario:

I have a buffer with a C file. I also have a command called clang_format that I have to invoke. That command takes the selected region as input and reformats it. What I want to achieve is reformatting the complete buffer avoiding to loose the current position of the cursor. My initial attempt is:

Code: Select all
class FormatBufferCommand(sublime_plugin.TextCommand):
  def run(self, edit):
    # Here I should save the current position of the cursor
    # Here I should restore the position

Can anyone help me to fill in the blanks?

Thanks in advance.
Posts: 1
Joined: Tue Jan 21, 2014 9:33 pm

Return to Technical Support

Who is online

Users browsing this forum: No registered users and 25 guests