- Как сменить редактор по умолчанию
- 🐹 CentOS 7/Debian/Ubuntu: Как изменить текстовый редактор по умолчанию?
- Содержание:
- 1. Введение.
- 2. Смена текстового редактора.
- 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
- Change default Linux / UNIX text editor from VI to Pico
- Set default text editor to pico
- Changing the default text editor on Linux
Как сменить редактор по умолчанию
Когда поставил себе цель уметь пользоваться чем-либо то нужно сразу же переключиться на задуманное, а не время от времени. Вот так и я. Я решил, хочу более сносно ориентироваться при использовании редактора именуемого 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’.
Источник
🐹 CentOS 7/Debian/Ubuntu: Как изменить текстовый редактор по умолчанию?
Опубликовано 2021-03-06 · Обновлено 2021-03-31
Содержание:
На чем было опробовано:
- CentOS Linux release 7.9.2009 (Core).
- Ноутбук Emachines.
1. Введение.
Как у каждого есть свои предпочтения в музыке и кино, так же у каждого есть свои предпочтения при выборе текстового редактора. Кто то не любит nano и предпочитает vim, другие обычно с удовольствием пользуются mcedit. Для изменения текстового редактора по умолчанию нужно всего пара действий.
2. Смена текстового редактора.
2.1. В CentOS 7.
По умолчанию используется редактор vi, проверить это можно командой:
Ответ: vi.
Поменяем редактор по умолчанию на mcedit.
Ответ:
2.2. В Debian/Ubuntu.
Посмотрим для начала установленный по умолчанию редактор:
# ls -l /etc/alternatives/editor
Ответ: lrwxrwxrwx 1 root root 18 Sep 30 12:57 /etc/alternatives/editor -> /usr/bin/vim.basic
По умолчанию стоит Vim.
Попробуем его поменять и поставить Nano.
# sudo update-alternatives —config editor
Ответ:
Появиться таблица со списком установленных редакторов , который имеет свой номер. Выбираем свой любимый редактор и вводим его номер. Теперь выбранный вами редактор, будет редактором по умолчанию.
Проверить что это именно так, можно повторно выполнив команду:
# ls -l /etc/alternatives/editor
Ответ: lrwxrwxrwx 1 root root 9 Sep 30 14:17 /etc/alternatives/editor -> /bin/nano
Источник
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”.
Источник
Change default Linux / UNIX text editor from VI to Pico
Q. I find vi hard to use. How do I change my default text editor from vim / vi to Pico under Debian Linux?
A. To use and change an editor to edit your text message, set the variable EDITOR to the pathname of the vi / vim binary file. You need to use export or set command for the same purpose.
Many Linux / UNIX command read shell EDITOR environment variable to determine which editor to use for editing a text file.
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
Set default text editor to pico
Type the command as follows:
$ which pico
Output:
Now setup a new text editor:
export EDITOR=/usr/bin/pico
OR
export EDITOR=pico
Add above line to
/.bashrc file:
$ vi
/.bashrc
Append text as follows:
export EDITOR=pico
Close and save the file. There is no no need to reboot system.
Also you can add alias if you want:
alias vi=/usr/bin/pico
🐧 Get the latest tutorials on Linux, Open Source & DevOps via
Category | List of Unix and Linux commands |
---|---|
Documentation | help • mandb • man • pinfo |
Disk space analyzers | df • duf • ncdu • pydf |
File Management | cat • cp • less • mkdir • more • tree |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Linux Desktop Apps | Skype • Spotify • VLC 3 |
Modern utilities | bat • exa |
Network Utilities | NetHogs • dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop |
Searching | ag • grep • whereis • which |
Shell builtins | compgen • echo • printf |
Text processing | cut • rev |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Comments on this entry are closed.
just a small suggestion:
alias pico=’nano -w’
thats because not every distro has pico symlinked to nano (nano is the open source pico) and because nano by default wraps long lines (-w).
also someone might be interested in seting TERM to linux
export TERM=linux
so he can use home/end/delete and numpad correctly in nano and also in shell
Источник
Changing the default text editor on Linux
The default command line text editor on Linux (and BSD varaiants) determines what is used when you run commands such as «crontab -e» and is often not what you want to use yourself. Typcially vi/vim is the default text editor; many people prefer emacs or other editors, and I prefer to use nano myself.
It’s easy to change this default text editor by using the system’s environment variables. Both the EDITOR and VISUAL environment variables determine which text editor is used at the default, and you can set either to change the default behaviour to the text editor you prefer like so from the command line:
The above example will make «nano» the default editor, and you can substitute «nano» for your preferred editor. You don’t have to specify the full path to the application, as long as it is located in one of the paths specified by the PATH variable, but it’s probably a good idea to, eg:
You can find the full path to a file using the «whereis» command like so:
Setting the EDITOR environment variable from the command line as shown above will only last as long as your current session; once you log out the default behaviour will apply again when you next log in. To make the change permanent, add the export value to your
Adding the entry to your
/.bash_profile file won’t take affect until it is re-read, which will happen when you log in again. You can re-read the file immediately by doing this:
To make the default editor change global and apply to all users, unless overridden in their
/.bash_profile file, you add the entry to the /etc/profile file.
Источник