Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect vi (not vim) in .vimrc?

Tags:

People also ask

Where can I find .vimrc file?

The global or system-wide vim configuration file is generally located under the /etc/vim/vimrc . This configuration file is applied to all users and when Vim is started this configuration file is read and Vim is configured according to this file contents.

How do I edit a vimrc file?

Opening vimrc Using file name completion, you could type :e $M then press Tab until you see the desired variable. If you only want to see the path, type :echo $M then press Tab to see the variable, and press Enter. In gvim, the Edit menu includes "Startup Settings" which will use $MYVIMRC to edit your vimrc file.


I carry a vimrc to all the machines that I work on and it naturally contains options that are not present in old vi.

If I accidentally start a vi session on a machine where vi is not an alias to vim and/or vim is not installed, vi reads vimrc and throws a bunch of annoying errors to let me know that option such and such are unsupported.

I know I can just always type "vim" instead of "vi" and set the EDITOR variable to vim (for visudo etc...), but is there a line I can add to the top of the vimrc that will exit the script early if the file is read by vi?