Sublime Forum

How to get all the text from the currently focues buffed?

#1

This is my first time wrestling with the sublime API and trying to create my first commands, so excuso my utter ignorance.

I’m browsing the API reference but I don’t see so far anything that allows me to do the following:

A) get all the text in the buffer as a string and store it in a variable
B) get all the text in the buffer line by line and store it as an array of strings in a variable.

What is the best idiom to achieve this? Thank you in advance

0 Likes

#2

To get the whole text:

self.window.active_view().substr(sublime.Region(0, view.size()))

And if you want it in an array of line just split by ‘\n’

0 Likes

#3

Thank you very much

0 Likes