Sublime Forum

Indent based on current indentation

#1

Hi all,

I’m trying to write a plugin which will insert a few lines in the program. These lines need to be indented based on the current indentation. For instance, if the user already has 4 tabs, my new lines should have 4 tabs as well. Preferably in the same format too - for instance, if a user chooses in their sublime options that they’d like space-based tabs, the tabs should be space based. I ctrl-f’d through the API and didn’t find anything. Would I have to do a regex hack or something?

If anyone has any ideas/code, that’d be great.

Thanks!
Matthew

0 Likes

#2

You can use insert_snippet to do this for you:

view.run_command('insert_snippet', {'contents': 'hello\n\nworld'})
0 Likes