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?

  • 3
    "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
  • 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
  • @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 '16 at 13:48

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.


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.

  • 5
    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
  • 2
    @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.

If you are on a Mac you might use a Vim Options application:

  1. Search for "nu", set "On".
  2. Search for "autoindent", set "On".
  3. Save the file as ".vimrc" in your home directory.

After that it's possible to transfer the vim config file to a remote SSH machine using "scp" command like:

scp ~/.vimrc moshe@professor.com

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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