Set Default Editor to nano
1. Draft
This document is draft. Please share suggestions with EdHeron.
2. Introduction
vi is a wonderful, full feature text editor. However, some might lack experience with vi and prefer a simpler text editor for quick configuration and crontab edits.
3. HowTo
3.1. Install nano
Installing nano is done using the yum system.
yum -y install nano
3.2. Disable Word Wrap
nano, by default, enables word wrap. While nice in a normal document, this is generally undesirable in a configuration file.
echo "set nowrap" >>/etc/nanorc
3.3. System Default Editor
During login, a number of scripts are run to setup the environment. In CentOS, a file for each subject is used. These are stored in a system profile directory, /etc/profile.d/. There are two environment variables that control which editor to use.
cat <<EOF >>/etc/profile.d/nano.sh export VISUAL="nano" export EDITOR="nano" EOF
3.4. Per User Default
If a user wishes to set the default editor for themselves, it can be, instead, be done in the user's bash profile.
cat <<EOF >>~/.bash_profile export VISUAL="nano" export EDITOR="nano" EOF
3.5. Activating Changes
Some of the changes made won't take effect on the current session. Log out and back in to activate the changes.
3.6. Testing
Scheduling jobs is one multi-layer process that uses a text editor. Editing the current user's scheduled jobs is one way to test which editor is the default.
crontab -e
If it is still vi, use :q to exit. If you are using nano, congratulations! Use ctrl-x to exit.
4. Setting Default Editor During Install
If installing nano and setting it as default editor during installation is desirable, some commands can be added to the kickstart file.
According to the documentation, name resolution isn't working correctly during the post installation script. To correct that, copy the resolver configuration from the install environment to the chroot environment. If the install environment is different from the runtime environment, specifically, if the name servers are different, make sure to correct the configuration file before the end of the %post install script.
%post --nochroot --log=/mnt/sysimage/root/install-post_.log cp -v /etc/resolv.conf /mnt/sysimage/etc/resolv.conf
Put the previously described commands in the %post section.
yum -y install nano echo "set nowrap" >>/etc/nanorc cat <<EOF >>/etc/profile.d/nano.sh export VISUAL="nano" export EDITOR="nano" EOF
5. Acknowledgements
MarcusMoeller for suggesting per user default
Document created by EdHeron.