Reputation: 1853
I have a small script that will generate a name in the pattern I would like. However, the filenames look very similar, which makes it tricky to find the new one in the list and open it. I can easily add the open in vim command at the end of the script, but what I would actually like would be the ability to have vim open and generate the new file and open it for editing.
In this way, vim could always be open in my terminal, I could switch to the terminal window and fire up a new note in the current directory with the proper name without ever leaving vim.
Upvotes: 1
Views: 311
Reputation: 705
This answer assumes that when you say generate a name
, you mean the script returns the name.
From your shell, you can do vim $(sh myscriptname)
and vim will open a file with the name of the output of myscriptname
.
From within vim itself, you can do :execute 'e '.system('sh myscriptname')
and vim will open a file similarly.
If you have a version of vim with clientserver
(do :echo has('clientserver')
to check), this can be significantly easier; however, the server is not automatically started in terminal vim so it requires a little configuration beforehand.
Upvotes: 1