I am running vim 8.2.2121.
I am trying to open 3 tabs
- One tab has instructions in it and is opened read only.
- Both tabs 2 and 3 create
:newfiles andreadtemplate files into them on separate tabs.
There are two mysteries in the vimscript / python code below...
Why can't I "template" the files into the buffer one after another?
Why can't I delay the running of a
vim.command()user command without it freezing?
I suspect the problem is that the User Commands are not running sequentially, but rather all at once, and thus some sleep is in order. But I have also tried running multiple commands in the same User Command prompt and I get the same result, three tabs, first file opens and the rest are empty.
function Init()
" Configure tabs in vim for different steps.
"
python3 << EOF
import vim
import time
setup_cmd_list = (
# Change to the project directory
'cd ~/projects/proj',
# Open the read me instructions, read only.
"silent view! ./README.md",
# Create a new buffer with filename der_file.txt
"new! der_file.txt",
# Read a template into the buffer...
"read $HOME/templates/template1.txt",
# MYSTERY_1: Open new tab (the new tab is opened, but none of the templates show up...???)
"tabnew",
# Create a new buffer with filename die_file.txt
"new! die_file.txt",
# Read a template into the buffer...
"read $HOME/templates/template2.txt",
# ...more stuff
)
for cmd in setup_cmd_list:
try:
# time.delay(300) # MYSTERY_2: Couldn't get this to work, it freezes vim in the terminal.
vim.command(cmd)
except vim.error:
print("fail! " + cmd)
EOF
endfunction
).