- Arch Linux
- #1 2007-06-03 14:59:45
- Where to set the default editor?
- #2 2007-06-03 15:14:01
- Re: Where to set the default editor?
- #3 2007-06-03 15:53:29
- Re: Where to set the default editor?
- #4 2007-06-03 15:59:56
- Re: Where to set the default editor?
- #5 2007-06-03 16:07:48
- Re: Where to set the default editor?
- #6 2007-06-03 17:33:50
- Re: Where to set the default editor?
- Как сменить редактор по умолчанию
- 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
Arch Linux
You are not logged in.
#1 2007-06-03 14:59:45
Where to set the default editor?
I can’t find a file to set the default editor to switch between nano and vim. I don’t want to change it using an environmental var since I want to do the change for all users.
I’m sorry if it’s a silly question.. Maybe I’m just too blind to see it.
#2 2007-06-03 15:14:01
Re: Where to set the default editor?
/etc/profile sources all files in /etc/profile.d/ which have the executable bit set.
So just write a file with
save it as /etc/profile.d/editor.sh and do chmod a+x on it. Next time you restart, this will be a global setting which can of course be overruled by the user’s own choice.
#3 2007-06-03 15:53:29
Re: Where to set the default editor?
Thanks for the reply, but I still wonder, where the setting for the default editor is stored. I don’t have a EDITOR variable set at the moment.
I’m just curious 😉
#4 2007-06-03 15:59:56
Re: Where to set the default editor?
Thanks for the reply, but I still wonder, where the setting for the default editor is stored. I don’t have a EDITOR variable set at the moment.
I’m just curious 😉
its set in the code for your shell.
#5 2007-06-03 16:07:48
Re: Where to set the default editor?
its set in the code for your shell.
Sry, but I don’t understand that. When you install Arch, you are offered to chose the default editor. If it was hardcoded, the shell would have to be recompiled while installing. Is that the case?
#6 2007-06-03 17:33:50
Re: Where to set the default editor?
its set in the code for your shell.
Sry, but I don’t understand that. When you install Arch, you are offered to chose the default editor. If it was hardcoded, the shell would have to be recompiled while installing. Is that the case?
I believe the editor you choose is only for the files you edit during the actual install. I could be wrong, but I don’t think it gets written to anywhere, and that the only reason you select one is that instead of typing: ‘nano /etc/rc.conf’ in the install is because you select the file you want to edit and the file appears on screen ready for modifications/lookover.
Last edited by Acid7711 (2007-06-03 17:36:25)
Источник
Как сменить редактор по умолчанию
Когда поставил себе цель уметь пользоваться чем-либо то нужно сразу же переключиться на задуманное, а не время от времени. Вот так и я. Я решил, хочу более сносно ориентироваться при использовании редактора именуемого 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’.
Источник
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”.
Источник