Trouble configuring terminal to use Vi keybindings

Edit: This was a misunderstanding on my part. I wanted the terminal to use vim keybindings and I mistakenly thought this was accomplished by setting the default editor. I am editing this post so that in the future it may help those with a similar lack of understanding. Thanks to everyone who helped me. This is my first time interacting with the Fedora community and it was very helpful. Thank you.

New Fedora user here. I’m having trouble setting my default editor to vim. I installed Vim using sudo dnf install vim-default-editor --allowerasing. As expected this uninstalled nano-default-editor. However, Vim is not the editor being used when I run a terminal. If I run echo $EDITOR the output is pointing to Vim:/usr/bin/vim. I’ve also tried setting environmental variables in ~/.bashrc and ~/.bash_profile. For example, export EDITOR=vim and export EDITOR=/usr/bin/vim. I’ve also tried the same thing in /etc/bashrc and /etc/profile. I’ve been at this for a while now so I figured I turn it over to the community to get some help. Thanks!

1 Like

Welcome to Ask Fedora, please take a minute and checkout New users! Start here! - Ask Fedora

Is vim-minimal or vim-enhanced installed?
sudo dnf list installed vim*

or is nano still running?

Thanks

I had a similar issue, and since I wanted both editors to be avialable, but to use vim by default had to make a small change in /etc/profile.d
What I did was copy /etc/profile.d/nano-default-editor.sh to /etc/profile.d/vim-default-editor.sh and edited the new vim-default-editor.sh to change the EDITOR from /usr/bin/nano to /usr/bin/vim.
By default only vim-minimal is installed, so to get the /usr/bin/vim I also had to install vim-enhanced (or use the minimal provided /usr/bin/vi)

I wanted nano to remain so I did not install vim-default-editor in place of nano-default-editor.

I then renamed the original nano-default-editor.sh to nano-default-editor.save

The next time I rebooted and logged in it had reset $EDITOR to point to vim and I was all set.

Wow, interesting. Since I already have vim-enhanced installed, then I tried to install with sudo dnf install vim-default-editor --allowerasing. It automatically remove nano-deafult-editor.

After successfully install vim-default-editor, look like the $EDITOR still pointing to nano. Then without did any modification to the system, I just reboot it. After reboot, the $EDITOR changed.

I can confirm that the default editor already changed bacause when I type virsh edit image-os it use vim instead of nano.

Also turn out it only change the default editor without removing installed nano.

Update:

The vim-editor-default look like adding script files inside /etc/profile.d/{vim-default-editor.csh,vim-default-editor.sh}.

Since it’s in /etc then it’s not something that can easily changed by reload the user session. I think it should reload the whole system/reboot.

vim-enhancedis installed. When I ran sudo dnf list installed nano* turns out that nano was still installed. So installing vim-default-editor only removed nano-default-editor. I removed nano and bash still doesn’t use Vim.

I tried this but it didn’t work for me. I removed all of my environment declarations, uninstalled nano, vim-enhanced, and vim-default-editor. Essentially creating a blank slate. Then I installed nano, nano-default-editor, and vim-enhanced. After that I followed these instructions. Again, echo $EDITOR returns /usr/bin/vim as expected but bash is still isn’t using Vim as the editor.

What command is using the wrong editor?

Correct. I am doing a reboot to test any changes I make to these files. vim-default-editor is executing as expected and setting $EDITOR=/usr/bin/vim.

I’m running gnome-terminal. So I’m attempting to use Vim in this context but it continues to use Nano. Never used Nano so I’m assuming it is Nano because it sure isn’t Vim. My understanding is that Nano is the default editor in Fedora.

If you type:
${EDITOR} at a command prompt does it run vim

Can you double check the output of:
which ${EDITOR}
alias
ls -l /usr/bin/vi*

${EDITOR} runs vim

$ which ${EDITOR} alias ls -l /usr/bin/vi*
/usr/bin/which: invalid option -- 'l'
alias ls='ls --color=auto'
	/usr/bin/ls
/usr/bin/vim
/usr/bin/alias
/usr/bin/vim
/usr/bin/vimdiff
/usr/bin/vimtutor
/usr/bin/virt-admin
/usr/bin/virt-host-validate
/usr/bin/virt-qemu-run
/usr/bin/virt-ssh-helper


You haven’t answered this.

My apologies. I’m afraid I don’t understand the question. I’m trying to setup my terminal to use the vim text editor keybindings. Typically in the past on other distros, setting an env variable in ~/.bashrc has sufficed.

So you’re trying to use vim bindings in the terminal with bash?

set -o vi

or you’re trying to open vim with Ctrl +x & Ctrl +e ?

export VISUAL='vim'

1 Like

Exactly. set -o vi works as it should but it isn’t persistent. How can I get it to be a persistent config?

1 Like

That should be in ~/.bashrc

echo "set -o vi" >> ~/.bashrc

1 Like

Oh if only you could see how hard I’m face palming right now… Super disappointed with myself on that one. That obviously works. Thank you!

2 Likes