- Как сменить редактор по умолчанию
- How to change default bash editor from vim to nano -Linux, CentOS
- Installing nano
- Finding the binary location
- Changing bash editor from vim or vi to nano
- For Individual User:
- Changing system wide configuration
- Checking the configuration
- Linux: how to change default editor
- Editor installation
- 1. Set the default editor for a single user profile
- 2. Set the default editor globally
- Final check
- Remarks
- How do I change the default text editor in Ubuntu
- 2 Answers 2
- Changing default crontab editor
- 10 Answers 10
Как сменить редактор по умолчанию
Когда поставил себе цель уметь пользоваться чем-либо то нужно сразу же переключиться на задуманное, а не время от времени. Вот так и я. Я решил, хочу более сносно ориентироваться при использовании редактора именуемого vim, а раз так то ниже пошаговые шаги по воплощении задуманного. Все дальнейшие действия происходят на рабочей/тестовой системе Ubuntu Trusty Desktop/Server.
Ранее я постоянно использовал редактор nano, а теперь хочу VIM.
$ sudo apt-get install vim -y
$ sudo update-alternatives —config editor
Есть 5 вариантов для альтернативы editor (предоставляет /usr/bin/editor).
Выбор Путь Приор Состояние
* 0 /bin/nano 40 автоматический режим
- 1 /bin/ed -100 ручной режим
- 2 /bin/nano 40 ручной режим
- 3 /usr/bin/mcedit 25 ручной режим
- 4 /usr/bin/vim.basic 30 ручной режим
- 5 /usr/bin/vim.tiny 10 ручной режим
Нажмите enter, чтобы сохранить текущий выбор[*], или введите выбранное число: 5
update-alternatives: используется /usr/bin/vim.tiny для предоставления /usr/bin/editor (editor) в ручной режим
Но и после этого при вызове sudo crontab -e все равно открывает редактирование через редактор nano, а я хочу через vim, как тогда сделать это?
touch: невозможно выполнить touch для «/home/ekzorchik/.selected_editor»: Отказано в доступе
$ ls -l /home/ekzorchik/.selected_editor
-rw-r—r— 1 root root 66 Jul 18 15:26 /home/ekzorchik/.selected_editor
$ sudo chown ekzorchik:ekzorchik
Select an editor. To change later, run ‘select-editor’.
Источник
How to change default bash editor from vim to nano -Linux, CentOS
This short tutorial will demonstrate how to change default command line (bash) editor in Linux and Unix type operating system. Most of the Linux distribution comes with vim or vi as default bash editor. Both are powerful editor, but I don’t like their interface. Here I’m going to demonstrate changing bash editor from vim to nano in CentOS 7.3 environment. Nano (developer’s link) is an advance command line editor with better interface. Same method is applicable for any other Linux or Unix distribution with bash as default command line.
Disclaimer: I’m running all installation commands as root user. So, I’m not using sudo. If you’re running a non root user with super user privilege append all installation and other necessary commands with sudo.
Difficulty: Easy Time Require: Less than 5 minutes.
Installing nano
In RHEL and CentOS nano is present in base repository and can be installed with yum as follows
yum install nano |
Same way, you can install nano in Debian and Ubuntu using apt-get
apt-get install nano |
Finding the binary location
You can find executable binary of any installed package using which as follows.
This will give the location of executable binary location, here “/usr/bin/nano”
If which which is not installed install it as follows
yum install which
apt-get install which
Changing bash editor from vim or vi to nano
For Individual User:
Edit or create “.bash_profile” or “.bashrc” in user’s home directory with your favorite editor
Append the file with following
A sample configuration file is as follows
From next time when you log into the system you’ll find nano as your default editor.
Changing system wide configuration
To change system wise default bash editor edit “/etc/bashrc” file and append it as follows
nano /etc/bashrc |
crontab -e |
If everything goes right you’ll find the nano interface as crontab editor instead vim or vi. If this is not in your case please follow the above steps once again
Serverlog thanks you for reading. For any difficulty please don’t forget to leave your comments bellow.
Источник
Linux: how to change default editor
Sometimes Linux default editor (usually “you” or “vim”) is not the most comfortable, especially for users that often use other editors like “nano”.
There are several online tutorials on how to change the default editor, but those procedures are often wrong and we realize that when, for example, we try to edit crontab (with the command crontab -e) and the old editor still come up.
In this article we will see how to change Linux default editor globally, or only for a specific user.
Editor installation
The first thing to do of course is to install, if not already present, the new editor (eg. “nano”), with the following command:
At this point you have two options:
1. Set the default editor for a single user profile
You will simply have to edit .bash_profile file of your profile (eg .: /root/.bash_profile or /home/nullalo/.bash_profile, or generally
/.bash.profile for currently logged in profile) and add the following lines:
2. Set the default editor globally
In this case you will have to edit /etc/bashrc file and add (possibly at the end of it) the following lines:
Final check
To make sure everything is ok, you need to disconnect and reconnect your user and ensure that with the following command:
new editor is used (in our case “nano”) in place of the old one (eg.: “vi”).
Remarks
Remember that the local editor, that is the one specified for a single profile, always overrides the global one: therefore, if you set “nano” in /etc/bashrc file and “vi” in the
/.bash_profile file, your profile will use “vi” as editor, and not “nano”.
The difference between the environment variables VISUAL and EDITOR is that EDITOR should be able to operate without the use of “advanced” terminal capabilities, while VISUAL may be a full screen editor such as vi or emacs. If you call an editor via bash, it will first try to use the editor defined in VISUAL, and in case of failure (maybe because terminal does not support a full-screen editor) it will use the editor defined in the variable EDITOR. The advice is to set EDITOR to the value “vi -e”.
Источник
How do I change the default text editor in Ubuntu
How can I change the default text editor for console programs in Ubuntu. When I run mutt and send a message, it currently loads up Joe and I would prefet to load Vim. I know I can change $EDITOR for me only, but would prefe to do it system wide.
2 Answers 2
You can change $EDITOR systemwide. Just drop a short script into /etc/profile.d/ which does this. The file only needs a single line:
There are two ways (at least :-/) in which a program can find an editor to launch. The traditional Unix/Linux mechanism is to use $EDITOR. In addition to that, Debian (and therefore Ubuntu) has special aliases for various kinds of programs. These are provided by the «alternatives» system (a system of configurable symlinks). For editors this provides the aliases editor and sensible-editor . These can be updated using update-alternatives:
(same for sensible-editor). This will prompt you for the editor to use.
However, in Debian programs are suppposed to read $EDITOR first:
Thus, every program that launches an editor or pager must use the EDITOR or PAGER environment variable to determine the editor or pager the user wishes to use. If these variables are not set, the programs /usr/bin/editor and /usr/bin/pager should be used, respectively.
These two files are managed through the dpkg «alternatives» mechanism.
If it is very hard to adapt a program to make use of the EDITOR or PAGER variables, that program may be configured to use /usr/bin/sensible-editor and /usr/bin/sensible-pager as the editor or pager program respectively.
In one sentence: Setting $EDITOR globally should be enough.
Источник
Changing default crontab editor
I am trying to change the default editor from nano to vim .
I have run the following commands:
sudo update-alternatives —config editor
update-alternatives —config editor
Both now output:
I have restarted my ssh session and restarted sshd but crontab -e still opens in nano
What else do I need to do?
10 Answers 10
Just simply run select-editor , this will let you choose any editor you want.
Try your ssh session followed by
The format of setting of the EDITOR variable depends on which shell you are using.
In Ubuntu you can set the EDITOR environment variable on logon by adding the above to the
Your SSH session will read a similar file (if it exists) on the remote host called
/.ssh/environment . This has to be specifically defined by the ssh daemon config. See man sshd_config and look for PermitUserEnvironment for more details.
My personal preference.
If you only want to choose the editor temporarily, you can do the following
This sets the EDITOR environment variable for the command
From «man crontab»:
Perhaps you have the EDITOR enivronment variable set to nano?
On my Ubuntu 12.04 computer, crontab uses the
/.selected_editor file, which contains the path of the selected editor. Edit it:
I have edited it directly or used select-editor , which is a script to do the same thing. Edit the following line:
IHMO people should not be changing anything in /etc or /bin to do this. It is a user level thing, not a system wide task.
I was having difficulties with select-editor and update-alternatives , my solution was to simply edit the link:
- sudo rm /etc/alternatives/editor
- sudo ln -s /usr/bin/vim /etc/alternatives/editor
editor now opens Vim
I’ve had the same problem — crontab -e relies on select-editor, visudo relies on the config of «alternatives»
run both commands as root
After trying the answers above, the only thing that worked for me (in Debian strech) was to remove
/.selected_editor by running:
And then select the new editor next time you run crontab -e .
In addition to checking that the environmental variable EDITOR is set correctly, you should also check to make sure the variable VISUAL is also set correctly.
VISUAL will override EDITOR
From the documentation:
The -e option is used to edit the current crontab using the editor specified by the VISUAL or EDITOR environment variables.
For example, if you set
Then the command crontab -e will still open in nano.
You should set both to be the editor of choice, ala vim for me:
Then the command crontab -e will open in vim.
Источник