python - Search and replace in current file with Sublime Text plugin -


i trying port sublime text build system plugin.

the build system receive current file , go through code:

for line in fileinput.input(inplace=1):     sys.stdout.write(makereplacements(line)) 

now, in plugin syntax go fact way current file's content is:

input = self.view.substr(   sublime.region(0, self.view.size()) ) 

but i'm not sure should next operation.

for line in input(inplace=1): 

how make replacements in file on-the-fly , save it?

i don't think sublime text plugin api can save buffer, use file_name() method in sublime.view class , work file directly.

as noted @mattdmo, file can saved using view.run_command('save').

it may easier use file name if old build file worked that.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -