Sublime Forum

Re-open file without close the window

#1

I’m working in a plugin where sometimes I need to move the file I’m working on to a new path, when it happens, I need to re-open it.

At this moment I’m doing that with:

window.run_command('close_file')
move(currentfilepath, newpath)
window.open_file(newpath)

I want to know if there is a better way to do this, I would like to avoid to close and re-open the ST windows

I was trying with:

move(currentfilepath, newpath)
view.file_name = newpath

But I suppose it doesn’t change the path in the buffer, does anyone knows if is possible to do something similar without close the current view?

0 Likes

#2

view.file_name is a method (see http://www.sublimetext.com/docs/3/api_reference.html#sublime.View or just type view.file_name in the ST console), so no, you can’t assign a new path to it that way…

I know there is a prompt_save_as command, but I’m not sure about a save_as command - maybe prompting is as close as you can get to not closing the tab in ST?

1 Like

#3

Thanks @kingkeith I hadn’t thought about “save as” as option, I’ll try it.
Once the file is saved, I just have to remove the duplicate file

0 Likes

#4

I’ve tried the prompt_save_as command but seems like there not way to avoid the prompt.

I’ve actived sublime.log_commands(True) but there is not other command after save the file, y also tried with run_command('prompt_save_as', {'path': 'filepath'}) without success

0 Likes

#5

I open old windows and it automatically closes the one I was working on, but I want the windows to stay up. What do I do?

0 Likes

#6

can you show us your code?

0 Likes

#7
2 Likes