Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
"mandated that you use Vim" ?! – Rook Feb 1 '12 at 12:50
Yup. That's the class text editor. – Moshe Feb 1 '12 at 14:02
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
+1 for your professor. – Bobby Marinoff Jun 20 at 7:55
@BobbyMarinoff haha yup. This was one of my early CS classes. The professor is (still) the only one in the department who teaches this way. – Moshe Jun 20 at 13:48
up vote 8 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

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
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 :/ – Rook Feb 1 '12 at 17:55
@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'. – marflar Jun 27 '14 at 9:00

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .