Home Download Buy Blog Forum Support

api method to get indentation character of the buffer?

api method to get indentation character of the buffer?

Postby jdc0589 on Fri Dec 02, 2011 10:51 pm

I know sublime dynamically figures out what the indentation character for a buffer is and uses that for tabs. Is this exposed in the API? I would love to be able to just call and api method to get the indentation character for the current buffer. I don't really care about setting it.

It looks like this might be on the Settings object returned by 'view.settings', but I cant find a list of keys anywhere.

Sorry if this is obvious in the documentation somewhere, apparently I suck at finding things in there.
jdc0589
 
Posts: 32
Joined: Fri Jun 03, 2011 2:32 am

Re: api method to get indentation character of the buffer?

Postby jps on Fri Dec 02, 2011 10:56 pm

You can work it out by querying the settings translate_tabs_to_spaces and tab_size. However, if you're just trying to insert indented text, then you can call view.insert with tab characters, and they'll be translated to spaces if required.
jps
Site Admin
 
Posts: 3058
Joined: Wed Mar 19, 2008 12:33 pm

Re: api method to get indentation character of the buffer?

Postby jdc0589 on Fri Dec 02, 2011 11:01 pm

jps wrote:You can work it out by querying the settings translate_tabs_to_spaces and tab_size. However, if you're just trying to insert indented text, then you can call view.insert with tab characters, and they'll be translated to spaces if required.


Thanks, forgot about those settings, haven't had to mess with them in the more recent builds. This is for my javascript formatting plugin, I just need the indentation character (and size actually) to pass to jsbeautifier so people only have to manage indent characters in one place. The settings values should do it
jdc0589
 
Posts: 32
Joined: Fri Jun 03, 2011 2:32 am


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 7 guests

cron