Vim Tips Wiki
m (Copyedits)
No edit summary
(8 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{review}}
 
 
{{TipImported
 
{{TipImported
 
|id=175
 
|id=175
Line 9: Line 8:
 
|version=5.7
 
|version=5.7
 
|rating=-1/21
 
|rating=-1/21
|category1=
+
|category1=Integration
 
|category2=
 
|category2=
 
}}
 
}}
 
Normally, typing edit on a Unix system brings up the vi editor and not Vim.
 
If you've installed Vim in your home directory somewhere,
 
If you've installed Vim in your home directory somewhere,
and you don't have a root account, and you want to
+
you don't have a root account, and you want to
 
make Vim the default editor for anything you do
 
make Vim the default editor for anything you do
(e.g. edit a SQL statement in SQLplus).
+
(e.g. edit a SQL statement in SQLplus), define these three variables in your .profile:
 
Normally typing edit brings up the vi editor and not Vim.
 
To solve this problem, define these three variables in your .profile
 
   
 
<pre>
 
<pre>
VIM=&lt;base directory where Vim executable is placed&gt;
+
VIM=<base directory where Vim executable is placed>
VIMRUNTIME=&lt;base directory where Vim runtimes are kept&gt;
+
VIMRUNTIME=<base directory where Vim runtimes are kept>
 
EDITOR=$VIM/vim
 
EDITOR=$VIM/vim
  +
  +
E.g:
  +
VIMRUNTIME=/usr/bin
  +
EDITOR=/usr/bin/vim
 
</pre>
 
</pre>
   
Note: If you've installed vim with another name (say, vim.exe) then
+
If you've installed vim with another name (say, vim.exe) then
 
change EDITOR=$VIM/vim to EDITOR=$VIM/vim.exe
 
change EDITOR=$VIM/vim to EDITOR=$VIM/vim.exe
   
Source the .profile, then the next time you start an editor from any
+
Source .profile, and the next time you start an editor from any
 
program you'll bring up Vim.
 
program you'll bring up Vim.
   
==Comments==
 
Notable programs which use the $EDITOR variable include CVS and Mutt. Anyone care to add to the list?
 
   
  +
On Ubuntu (or other Debian-based systems), update-alternatives can be used to change the default editor:
----
 
  +
<pre>
$EDITOR is the place to have your editor defined. There's also $VISUAL to define a non-line oriented editor (which is actually vi's place).
 
  +
sudo update-alternatives --config editor
All programs on unixlikes spawning editors should support these. Some have reasons not to and some are just stupidly made and others stupidly configured.
 
  +
# Type the number which corresponds to Vim here (after installing it) then press Enter.
  +
</pre>
   
  +
$EDITOR is the defined variable that programs on Unix-like operating systems are supposed to use for the default editor. Actually, $VISUAL is another defined variable for a non line-oriented editor, which is technically the correct role for Vim. Many notable programs on Unix support these variables, though obviously there are a few that for various reasons do not.
----
 
  +
 
==Comments==

Revision as of 13:26, 15 July 2013

Tip 175 Printable Monobook Previous Next

created December 6, 2001 · complexity basic · author bhaskar · version 5.7


Normally, typing edit on a Unix system brings up the vi editor and not Vim. If you've installed Vim in your home directory somewhere, you don't have a root account, and you want to make Vim the default editor for anything you do (e.g. edit a SQL statement in SQLplus), define these three variables in your .profile:

VIM=<base directory where Vim executable is placed>
VIMRUNTIME=<base directory where Vim runtimes are kept>
EDITOR=$VIM/vim

E.g:
VIMRUNTIME=/usr/bin
EDITOR=/usr/bin/vim

If you've installed vim with another name (say, vim.exe) then change EDITOR=$VIM/vim to EDITOR=$VIM/vim.exe

Source .profile, and the next time you start an editor from any program you'll bring up Vim.


On Ubuntu (or other Debian-based systems), update-alternatives can be used to change the default editor:

sudo update-alternatives --config editor
# Type the number which corresponds to Vim here (after installing it) then press Enter.

$EDITOR is the defined variable that programs on Unix-like operating systems are supposed to use for the default editor. Actually, $VISUAL is another defined variable for a non line-oriented editor, which is technically the correct role for Vim. Many notable programs on Unix support these variables, though obviously there are a few that for various reasons do not.

Comments