0

I'm using iTerm2 with vim to work with python files. When I create or start editing a file using 'vi', I always have to introduce all the configuration values like ':set number', ':syntax on', etc. I have edited '.vimrc' from MacVim to save this parameters, but when I restart iTerm I have to put the values again, the configuration didn't save this 'set' values.

This is an example how i start the program: 'vi file.py'. It opens vim but without the 'set' values I have previously introduced.

It would be nice if someone could help me. Thank you.

coyr
  • 659
  • 6
  • 9
  • where is your .vimrc, what is actually in it? Are you sure you're running vim when typing vi? if you do `vim file.py` is the result any different? – Ryan Haining Dec 06 '14 at 23:06
  • Hi @Ryan, I have installed MacVim and iTerm2. The '.vimrc' is in 'applications/MacVim/Contents/Resources/vim/.vimrc'. I think I running vim because I can edit like when I use vim. If I use 'vim file.py' instead 'vi file.py' nothing change, the file still open. Thank you for your help. – coyr Dec 07 '14 at 02:10
  • The content of the file is too long. This is a fragment: ` set nocompatible set guifont=Monaco:h14 set guioptions-=T set ruler set history=100 set encoding=utf-8 set fileencodings=utf-8,latin-1,chinese syntax on set number set tabstop=8 set shiftwidth=4 set expandtab set autoindent set smartindent ` – coyr Dec 07 '14 at 02:21

1 Answers1

1
  1. First rule: NEVER DO ANYTHING IN VIM'S RUNTIME FILES.

    In Vim, do :echo $VIM. That directory, /Applications/MacVim.app/Contents/Resources/vim, in your case, is off limits. You are not supposed to change/add/remove anything, there. There's no good reason to even look at it!

  2. Second rule: ALWAYS DO CUSTOMIZATION IN YOUR HOME DIRECTORY.

    Your customization belongs to your home directory.

    Your vimrc is here:

    ~/.vimrc    ~/ being a shortcut for /Users/username/
    

    Your vim/ is here:

    ~/.vim/     ~/ being a shortcut for /Users/username/
    

    You must create those files and directories if they don't already exist.

Note: MacVim is a GUI app that won't work in your terminal unless you did some (simple) specific things. Did you do anything toward that goal? It looks like you are just using the default Vim that will obviously not source MacVim's runtime files.

romainl
  • 186,200
  • 21
  • 280
  • 313
  • Ok, got the rules. In MacVim I delete the lines I had added. I created the file and directory in ~/ and then I added the lines in .vimrc but iTerm still isn't showing the rules. Thanks for your help. – coyr Dec 07 '14 at 11:31
  • I find this function that help us to see what files are loaded: `:scriptnames`. If you don't see your `/Users/username/.vimrc` file in the list, then something is wrong. In my case the file wasn't starting with '.'. You can't edit the filename directly in Finder. I find this solution: Open your terminal and write: `> cd /Users/username/ > mv vimrc .vimrc`. Then if you want to edit the `.vimrc` file you can do it using `:e $MYVIMRC` – coyr Dec 12 '14 at 04:13