Tuesday, June 26, 2012

Re: Can vim be made to start with selected files already open?

I started to write a reply and it is just too lengthy (as are the remarks here). Here is what I wrote:

http://securemecca.com/public/MacVimHelp.txt

I really don't think you want to change what vim loads up by default. Sooner or later you won't want that kind of startup any more. What you want is an alternative method to open up the other files (perhaps learning files?) for a while. If you are using a terminal with the bash shell and that is all you do you could easily do this the first time:

$ vim file1.txt file2.txt file3.txt

The $ just means a shell prompt. If you close vim, thereafter all you would need to do is type the following in the terminal (do it often enough so the command doesn't disappear from the bash history) as long as you always want to do the same thing:

$ !vim
# if you get the wrong thing
$ history | grep vim | grep -v grep
# (the second will show all of them and if there is more than one then:
$ !236
# that would start the vim the same way it was on line 236

That of course assumes the name for starting vim is vim (maybe, maybe not on Macintosh - they want to do everything different). On most versions of Linux, FreeBSD, OpenBSD, and Sun Solaris, vim is what is run in a terminal. gvim is the GUI version on Gnome. I have no idea what the replacement for gvim is with the Unity GUI. The version of KDE I used named the GUI version kvim but it was GUI choose at boot and it also had gvim and Gnome on the system.

I can assure you that double clicking on the above script DID start gvimi and it DID open up the specified files. Basically, I just copied my gvimi script in my ${HOME}/bin to ${HOME}/Desktop/vimstart and replaced the "$*" with the names of the files in vimstart. This is very similar to anderson howl's tip, but his tip depends on you being able to give the vimf command somehow. That would necessitate a change in your .bashrc and vimf would have to be run in a terminal unless you have some way of running the command outside the terminal (special launcher?). But I wouldn't change .vimrc to do this. Some of the other ways specified here will also work but require some typing after vim is up and running if you don't use the terminal. For my script method, nothing needs to be changed in the .vimrc, the .bashrc or other bash startup files, and it is sitting there on the desktop. Well it was sitting there, I just deleted it but I can recreate it in just a few seconds. Believe it or not the terminal and bash are your good friends and some times you can do things much easier there than you can in a GUI.

Why are Macintosh people so reluctant to use the terminal and bash? They are great when you are always doing the same kind of thing repeatedly. They are infinitely better than the GUI for repeatable things like this. Not only that, you start to see how things are put together. Einstein said, make every system as simple as possible and no simpler. Mac OS-X went past that on the simplification. It ends up making things like this which are easy for me very difficult for you. I know because I owned a Next machine and it is very similar to Mac OS-X. It took less than 30 seconds to create that script on my desktop. Oh yes, you probably don't want to delete your vim history. I don't want it at all since I have at least 8 xterms for me and one for root in four work spaces with a huge screen to do what I do. Getting 6-7 vims running with all of them adding their stuff to the history gets confusing and I am almost never going back to where I was in the file. For C programming I just minimize vim, do the make and test and bring vim right back up which is exactly where I was to make changes. Recover? Save as often as you need to avoid loss of editing. For me that is a simple ESC F8. If you cannot afford to lose it, save.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: