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

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -