Home Download Buy Blog Forum Support

How does clone command work?

How does clone command work?

Postby Esente on Tue Aug 24, 2010 8:06 pm

Dear admin,

I would like to create some plugin that would do what clone commands does right now, that is, create an exact copy of a buffer, and any change in one view will be reflected in the other.

Therefore I would like to know how that command works, how I could call it from the console, and how to use it in my plugin? It looks like it is part of the closed source part of Sublime.
Esente
 
Posts: 26
Joined: Mon Aug 16, 2010 7:20 pm

Re: How does clone command work?

Postby gpfsmurf on Tue Aug 24, 2010 8:59 pm

Try this:
Code: Select all
window.runCommand("clone")


Commands reference: http://www.sublimetext.com/docs/commands
gpfsmurf
 
Posts: 211
Joined: Mon Jun 23, 2008 6:31 pm

Re: How does clone command work?

Postby Esente on Tue Aug 24, 2010 9:11 pm

gpfsmurf wrote:Try this:
Code: Select all
window.runCommand("clone")


Commands reference: http://www.sublimetext.com/docs/commands


Awesome. How could I have missed that?

Now I know how to call that command, is there anyway we could control how it behaves? For example, I don't want to clone the buffer to another view, but instead store it into a variable and create a view later, on another instance of Sublime.
Esente
 
Posts: 26
Joined: Mon Aug 16, 2010 7:20 pm

Re: How does clone command work?

Postby gpfsmurf on Tue Aug 24, 2010 9:49 pm

Esente wrote:Now I know how to call that command, is there anyway we could control how it behaves? For example, I don't want to clone the buffer to another view, but instead store it into a variable and create a view later, on another instance of Sublime.


You could store the filename in a variable, and then use the 'open' command later.
gpfsmurf
 
Posts: 211
Joined: Mon Jun 23, 2008 6:31 pm

Re: How does clone command work?

Postby Esente on Wed Aug 25, 2010 6:40 am

But will the file opened by "open" command has the features of cloning? Like changes in one view is reflected in the other view?
Esente
 
Posts: 26
Joined: Mon Aug 16, 2010 7:20 pm

Re: How does clone command work?

Postby gpfsmurf on Wed Aug 25, 2010 7:25 pm

Actually no, I just tested it.

If you open a file which is already open in the current window, it will switch to that tab instead.
If you open a file which is open in a different window, it will open it, but changes won't be reflected in the other window.

So I don't know of a way to clone a view in a new sublime window. It looks like it only works in the same window... But it's still quite handy with double panes.
gpfsmurf
 
Posts: 211
Joined: Mon Jun 23, 2008 6:31 pm

Re: How does clone command work?

Postby Esente on Thu Aug 26, 2010 6:56 pm

Yeah, I have dual-monitor, so having two windows of Sublime on each monitor each would come in handy. If I could know how the clone works, I could reuse it to make a simple plugin that allows what I want.
Esente
 
Posts: 26
Joined: Mon Aug 16, 2010 7:20 pm


Return to Technical Support

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot], Yahoo [Bot] and 26 guests