Score:2

How do I change the editor form vim to nano?

kr flag

While using the command sudo apt edit-sources, accidentally chose vim instead of nano and don't know how to change it. I used sudo update-alternatives --config editor but it doesn't change the editor I use in the sudo apt edit-sources command.

KK Patel avatar
in flag
Does this answer your question? [How do I change the default text editor?](https://askubuntu.com/questions/13447/how-do-i-change-the-default-text-editor)
bac0n avatar
cn flag
apt uses `/usr/bin/select-editor` (it creates a file in HOME .selected_editor, if you delete it you will get to choose again)
LyingAmigo avatar
kr flag
I can't find HOME.selected_editor so I deleted select-editor in /usr/bin/select-editor but even that dosent seem to work.
bac0n avatar
cn flag
`apt-get --reinstall install sensible-utils` will give you `select-editor` back, run it to get the menu.
bac0n avatar
cn flag
In short, apt edit-sources uses `Dir::Bin::Editor` as default editor, which defaults to `sensible-editor`, this is a shell wrapper trying to make sense of which editor to use if neither EDITOR nor SELECTED_EDITOR is set `sensible-editor` will try to start `select-editor` which creates and sources the file `~/.selected_editor` before calling the *selected editor*, I think the order is $VISUAL, $EDITOR, $SELECTED_EDITOR and last editor.
bac0n avatar
cn flag
sorry `nano` is last
LyingAmigo avatar
kr flag
I really appreciate all the information about the order of completion and that command did bring back 'select-editor' and when I ran it I got to choose again but the problem is still there. When I run 'sudo apt edit-sources' vim opens. I am not that familiar with vim so I am kinda stuck and I think I will reinstall the OS if can't fix it.
muru avatar
us flag
If you ran this with sudo, look for the file in root's home directory not your own.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.