1

My centos 7 has two vim binaries:
/usr/bin/vi
/usr/bin/vim

When launching either of them they bring up:

VIM - Vi IMproved
version 7.4.1099

From searching around online I believe that these two versions are vim and vim-minimal. The problem is that vi and vim-minimal interpert the ~/.vimrc differently. When opening vim its great. When opening vim-minimal I get lots of errors. Below is a representation of my ~/.vimrc file:

set number
set nowrap
set modeline
set clipboard=unnamedplus  "Enables mouse center clip pasting, while holding shift, in insert mode.

"Below sets up the mouse in such a way that allows vi split screen resizing while in tmux and screen.
set mouse+=a
if &term =~ '^screen'
    " tmux knows the extended mouse mode
    set ttymouse=xterm2
endif

""""""""""""""""""""""""""""""""""""""""""""""""
""" User Defined Functions
""""""""""""""""""""""""""""""""""""""""""""""""
"Opens up sage specific work in new tabs
fu! Setup1()
  :bd!|e /home/me/example1.h | vsplit /home/me/example1.cc
  :tabnew /home/me/example2.h | vsplit /home/me/example2.cc
  :tabnew /home/me/example3.h | vsplit /home/me/example3.cc
  :tabnew /home/me/example4.h | vsplit /home/me/example4.cc
  :tabnew /home/me/example5.h | vsplit /home/me/example5.cc
  :tabnew /home/me/example6.h | vsplit /home/me/example6.cc
endfunction

"Opens up the most edited rc files in new tabs
fu! RCS()
  :bd!|e ~/.cshrc
  :tabnew ~/.vimrc
  :tabnew ~/.tmux.conf
endfunction

The problem is my user defined functions. When /usr/bin/vi is opened it opens all of the documents in my two functions in new tabs. A resonable workaround would be to not use /usr/bin/vi but it is what git opens.

Ideally I would be able to have an if statement that checks what binary is running this rc file. Is that possible?

Colonel
  • 19
  • 4

2 Answers2

2

You can configure git to use the editor of your choice. You can set the environment variable GIT_EDITOR or you can set a configuration file with git config --global core.editor /usr/bin/vim to set the core.editor variable.

If neither of those is set, it may fall back to the VISUAL environment variable. On that note, you will likely want to set that in your ~/.bashrc as a more system-wide solution so other utilities that may want to open an editor default to /usr/bin/vim over /usr/bin/vi

Christian Gibbons
  • 4,272
  • 1
  • 16
  • 29
0

The following blog post discusses how to degrade vimrc for different builds of vim that may have different packages and different capabilities (and thus react to vimrc differently):

gracefully degrading .vimrc

(answer provided by max630 in the comments to my question)

Colonel
  • 19
  • 4