python script to edit a file in vim -


i want make python script that:
opens file, executes command i,
writes 2 lines of code, hits escape
executes command zz.
thinking along lines of os.system("vi program") os.system("i") , os.system("code"), didn't work because can execute commands. thank you!

the code

import pyautogui multiprocessing import process import os  vi_proc = process(target = lambda: os.system("vi program")) vi_proc.start()  pyautogui.typewrite("i") pyautogui.typewrite("this code\n") pyautogui.typewrite("really sucks!") pyautogui.press("esc") pyautogui.typewrite("zz")  vi_proc.join() 

the blablabla

well, not understand why, coded working solution. used pyautogui, simple library allow emulate key , mouse presses , movements.

you may need install sysyem package, libjpeg8-dev. furthermore, have issue command xhost + temporarily before installation.

that said, in bash simply:

echo -e "this code\nreally sucks!" > program 

Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -