Home Download Buy Blog Forum Support

Set Syntax for View?

Set Syntax for View?

Postby kvangork on Wed Feb 02, 2011 10:24 pm

I'm trying to create a keyboard shortcut to set an unsaved file's syntax.
view.syntax_name(view.buffer_id()) in the console returns the correct type for files already saved, but I can't figure out how to set it.

Thanks,
Kirk
kvangork
 
Posts: 1
Joined: Wed Feb 02, 2011 10:21 pm

Re: Set Syntax for View?

Postby n00ge on Wed Feb 02, 2011 11:18 pm

I think when the quick panel API becomes available that will make a syntax selection tool much better.
http://twitter.com/n00ge
Sublime Text 3 dev builds | OS X 10.8.2 & Ubuntu 13.04
n00ge
 
Posts: 140
Joined: Mon Oct 05, 2009 1:23 am

Re: Set Syntax for View?

Postby adzenith on Thu Feb 03, 2011 9:18 pm

Try something like this:
view.settings().set('syntax', 'Packages/'+ syntax + '/' + syntax + '.tmLanguage')
adzenith
 
Posts: 1216
Joined: Mon Oct 19, 2009 9:12 pm

Re: Set Syntax for View?

Postby stiang on Sat Feb 05, 2011 9:01 am

Isn’t view.settings().set() implemented in the ST2 alpha? The syntax doesn’t appear to change when I execute

Code: Select all
view.settings().set('syntax', 'Packages/'+ syntax + '/' + syntax + '.tmLanguage')
where syntax is "XML", for example.

I’m trying to implement the DetectFileType plugin in ST2, to be able to detect .html.erb etc. in a reliable way.
stiang
 
Posts: 39
Joined: Sat Jan 29, 2011 12:34 pm

Re: Set Syntax for View?

Postby jps on Sat Feb 05, 2011 9:53 am

view.settings().set() should work, but isn't the best way to change the syntax in any case, as it won't cause the right .sublime-settings files to be associated with the view.

There will be a new API function, view.set_syntax_name(), in the next version.
jps
Site Admin
 
Posts: 3067
Joined: Wed Mar 19, 2008 12:33 pm

Re: Set Syntax for View?

Postby gpfsmurf on Tue Feb 08, 2011 4:58 pm

jps wrote:view.settings().set() should work, but isn't the best way to change the syntax in any case, as it won't cause the right .sublime-settings files to be associated with the view.


Is this an issue in 1.x as well?
gpfsmurf
 
Posts: 211
Joined: Mon Jun 23, 2008 6:31 pm

Re: Set Syntax for View?

Postby jps on Tue Feb 08, 2011 7:47 pm

Yep
jps
Site Admin
 
Posts: 3067
Joined: Wed Mar 19, 2008 12:33 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 44 guests