Reputation: 992
I work on multiple MAC OS X systems, which do not save changes after log out. As you know VIM is on every new mac, just type in vim in the terminal. I always bring my vimrc file with me, and the problem is that every single time I start vim i have to load it with :so
command.
I want to use the fact that vim is available on every unix, but I also want to take advantage of the nifty integration with the terminal for doing quick tests, I just switch back to the terminal, but for that I need to close vim. When I reopen it, I again have to load the vimrc. And I am a newb, I don't even have plugins yet...
I want to keep the integration with the terminal and only develop a super quick way of introducing my changes to vim. Think of the conditions as if though you are sitting on newly installed operating system.
Thanks !
Upvotes: 2
Views: 2681
Reputation: 196789
How is it possible that your changes are not saved after you log out? What would be the point of such a machine? An internet kiosk in an airport? Do you log as a user without a "home" directory?
If you have a "home" directory, just create a blank ~/.vimrc
and put your settings there.
If you don't have a "home" directory but you are able to write somewhere else, create a blank vimrc
file where you can, write your settings there and learn this command by heart:
$ vim -u /path/to/your/vimrc
If you don't have a "home" directory and you are really sure that you can't save anything on these machines, put your settings in a file somewhere online, preferably a place under your control, and learn this command by heart:
$ vim -u http://domain.name/yourvimrc
If you are lucky, the command you use will be remembered by your shell for you and it will be easy to issue it again without much typing.
For running your tests, you can either:
Hit <C-z>
to suspend Vim. You are back at the prompt from where you started Vim and you can do your thing. Type $ fg
to go back to Vim.
Type :sh
to launch a new shell from the current directory. To go back to Vim, type $ exit
.
Upvotes: 2
Reputation: 1321
Not directly to your question, but you can always invoke vim with -u
, which will let you specify your vimrc file instead of launching vim and then running :so
.
The default location for your .vimrc
file is ~/.vimrc
(on the mac, ~
is /Users/_you_
, eg /Users/matt
). If you can write your file there, it will be loaded when vim starts up every time.
The system vimrc file on the mac is at /usr/share/vim/vimrc
, but it sounds like these systems are not under your control, so you won't be able to write that file. Have a look at: How can I override ~/.vim and ~/.vimrc paths (but no others) in vim?, which uses the -u
option to change the path vim looks for plugins under. But, in all cases, you must either be able to write your .vimrc
into your home directory (which it sounds like your system does not permit) or specify the path to it at runtime (as with the command-line option I mention above, or with the normal command :so
which you're currently using).
Depending on the kind of testing you need to do, you can always run shell commands within vim, by using the !
in normal mode. For instance, I frequently make changes to a python file in a buffer, and then (in normal mode) run !nosetests
within vim—that writes terminal output into a temporary buffer at the bottom, and doesn't require me to leave or suspend vim. I can review the output, and any key-press takes me back to my buffer.
Upvotes: 5
Reputation: 195219
I don't have any experience with Mac-Os terminal. However I think if you could cp your .vimrc file to your home directory. everytime you start vim, vim will load the .vimrc file from your home directory.
If you want to swtich back to terminal from vim to do some testing/execute some commands and back to vim. you could consider to:
If you want to sync your .vimrc on different machines, you could put your .vimrc file in
a scm repository like gitHub, bitbucket... (I perfer this option, since you could have different branches for different settings)
dropbox
I hope this helps.
Upvotes: 3