Replacing vi with nano - permanently

Every day solutions to every day challenges. + Brilliant stuff

Moderators: b1o, jkerr82508

Forum rules
Please feel free to post your tip it does not have to be advanced. Also ask questions directly related to the tip here. But do not start new threads with questions or ask for help here. That is what the help section is for. forum rules: http://bjoernvold.com/forum/viewtopic.php?f=8&t=568
User avatar
viking60
Über-Berserk
Posts: 9351
Joined: 14 Mar 2010, 16:34

Replacing vi with nano - permanently

Postby viking60 » 03 Feb 2014, 12:24

Many people prefer to have nano as the default terminal editor. On most cases we simply specify nano as the editor so it does not matter.
But when working with cron jobs you will be put into the vi - environment if you do a simple:

Code: Select all

crontab -e

To make sure it opens with nano you can simply put this in your ~/.bashrc

Code: Select all

export EDITOR=nano


Reboot or type:

Code: Select all

source .bashrc

and type crontab -e again; this time it will be opened in nano. :tux5:
Manjaro 64bit on the main box -Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz and nVidia Corporation GT200b [GeForce GTX 275] (rev a1. + Centos on the server - Arch on the laptop.
"There are no stupid questions - Only stupid answers!"

jkerr82508
Guru-Berserk
Posts: 211
Joined: 16 Oct 2010, 21:45
Location: Fife, Scotland

Re: Replacing vi with nano - permanently

Postby jkerr82508 » 03 Feb 2014, 14:07

I always add it to /root/.bashrc as well as ~/.bashrc since I have some cron jobs that need to run as root. Doing so also means that visudo uses nano, rather than vi.

I also always add to both:

Code: Select all

export VISUAL=nano
To be quite honest, I've forgotten why I do the latter. :?:

Jim

User avatar
viking60
Über-Berserk
Posts: 9351
Joined: 14 Mar 2010, 16:34

Re: Replacing vi with nano - permanently

Postby viking60 » 03 Feb 2014, 16:56

Good tip there Jim.
It might well come in handy to do a cronjob to backup /etc and then you need to be root. +1
So yes a:

Code: Select all

su
password
nano .bashrc

and putting

Code: Select all

export EDITOR=nano

in there, makes a lot of sense.

Regarding

Code: Select all

export VISUAL=nano
I have seen people refer to it and use it - but I cannot see why either :confused

Even visudo will open in nano after vi have fixed the root .bashrc afaict
Manjaro 64bit on the main box -Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz and nVidia Corporation GT200b [GeForce GTX 275] (rev a1. + Centos on the server - Arch on the laptop.
"There are no stupid questions - Only stupid answers!"

User avatar
jemadux
Viking
Posts: 37
Joined: 13 Oct 2010, 19:07

Re: Replacing vi with nano - permanently

Postby jemadux » 04 Feb 2014, 12:20

i dont like vi ..but i prefer vim ..
sometimes i am using nano for specifics files ..
on my archlinux machine I have removed vi and i made a syblick to vim

Code: Select all

ln -s /bin/vim /bin/vi


Return to “Tips & Tricks”