Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

My professor assigned an ssh account to every student in my programming class and mandated that we use VIM for text editing. I discovered :set nu and :set auto indent via Google. I noticed that those two settings reset after every launch. Is there a way to make them persist on my ssh account? What about on VIM on my local machine?

share|improve this question
2  
"mandated that you use Vim" ?! –  ldigas Feb 1 '12 at 12:50
    
Yup. That's the class text editor. –  Moshe Feb 1 '12 at 14:02
1  
On either your ssh account or your local machine, execute vimtutor. That will help you learn how to use Vim. When you're done with that, execute :help within Vim to see an overview of how to use the help system and some more introductory reading. –  garyjohn Feb 1 '12 at 15:49
add comment

3 Answers

up vote 4 down vote accepted

Put them in your vimrc (see :help vimrc). You can then sync that file between machines.

Another option is to have vimrc set up on the local machine, and use e.g. bcvi to transfer files transparently from remote to local and back again.

share|improve this answer
add comment

When you are in Vim, type :echo $VIM ... that should give you the location where your _vimrc (or .vimrc) should go. Edit a file under that name, put those two lines inside

   set nocompatible
   set number
   set autoindent

and save it.

Yell if you have any problems with this.

share|improve this answer
2  
No, $VIM is not where your _vimrc or .vimrc should go. Those files should go in $HOME. –  garyjohn Feb 1 '12 at 15:46
    
@garyjohn - Says who? Putting them in $HOME on Windows creates two possible problems; one - HOME creates a hard to make portable installation, and two, it may already be taken by emacs :/ –  ldigas Feb 1 '12 at 17:55
1  
@Idigas: Because $VIM is accessible by all users. It may be OK on a personal computer used by only one person, but it is not OK on a multi-user Unix system, as the poster's ssh account presumably is. I don't understand how using $HOME makes it less portable, unless you have Vim installed on a thumb drive, but that wasn't being discussed. Emacs's use of $HOME or anything else should not have anything to do with where one puts ones _vimrc or .vimrc. –  garyjohn Feb 1 '12 at 18:57
    
According to :help vimrc, $VIM is possibly Mac thing. Just sayin'. –  stephenmurdoch Jun 27 at 9:00
add comment

There is also the modeline where you can configure vim file-wise and are not dependent on any local vim configuration.

  • One can customise the behaviour of vim for specific files using modelines.
  • Modelines are included at the beginning/end of the file and invoke "setlocal" on vim variables.
  • This is useful for setting options like the behaviour of tabs, the file mode , etc.
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.