Sublime Forum

Changing all views in current window

#1

I am trying to make changes to all views in the current window. I am able to access and process each view, but changes using view.insert() and view.update() only occur in the current view.
I am using version 4169

window = self.view.window()
    update_count = 0

    if window:
        # Iterate through all open views in the window
        for view_to_update in window.views():
            view_to_update.insert(edit, 0, 'new_content\n')
0 Likes

#2

The edit token that the run() method of a TextCommand gets is only valid for editing the buffer that the command was called for (i.e. self.view).

If you want to edit multiple views, then you need to implement a TextCommand that can make the edit for you and then iterate calling run_command() on each view.

0 Likes

#3

Thanks for the response.

0 Likes