Text editor

From Gentoo Wiki
Jump to: navigation, search
Resources

A text editor is a program to create and edit of text files. Although it is not impossible to edit files without using one, text editors make it easy to edit configuration files. The Gentoo @system set contains the virtual/editor package to make sure at least one editor is installed.

Software

Program Skill level Features Note
nano Easy Advanced Gentoo default
Emacs Advanced Huge
Vim Advanced Huge

More text editor options can be found online in the app-editors category or by running:

user $eix "app-editors/*"

Vim and Vi

If Vim is installed the vi and vim commands become synonymous due to the following link:

user $ls -al /usr/bin/vi
lrwxrwxrwx 1 root root 3 Nov 25 19:59 /usr/bin/vi -> vim

The synonymous use also holds for setting editor defaults.

Sudo editor

sudo does not preserve the user's environment variables and therefore may have a different default editor.

Visudo editor

Due to the sensitive nature of /etc/sudoers it may only edited via the visudo command which in turn is limited to a predefined selection of editors. Type man visudo for more information.

Setting system default

The system wide default text editor can be defined in the /etc/env.d/99editor file. To change the Gentoo system default from nano to Vim add the path to Vim's executable:

FILE /etc/env.d/99editorChanging system wide text editor default
EDITOR="/usr/bin/vim"

The system default editor can also be set with the eselect utility. Replace <NUMBER> in the following command with a number corresponding to the text editor of choice:

root #eselect editor list
Available targets for the EDITOR variable:
  [1]   /bin/nano
  [2]   /bin/ed
  [3]   /usr/bin/emacs
  [4]   /usr/bin/ex
  [5]   /usr/bin/vi
  [ ]   (free form)
root #eselect editor set <NUMBER>

Actually eselect modifies the file above.

The old method of setting the EDITOR variable in /etc/rc.conf is no longer supported. See this article for details.