Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure neovim with update-alternatives for ex view and vimdiff behaviours?

Of course, we could create aliases, but then we loose the Debian integration. For instance, the 3 first works, as they are just aliases, but the 3 last fails:

NVIM_PATH=/usr/local/bin/nvim
update-alternatives --install /usr/bin/vi vi "${NVIM_PATH}" 110
update-alternatives --install /usr/bin/vim vim "${NVIM_PATH}" 110
update-alternatives --install /usr/bin/editor neovim /usr/local/bin/nvim 110
update-alternatives --install /usr/bin/view view "${NVIM_PATH}" 110
update-alternatives --install /usr/bin/vimdiff vimdiff "${NVIM_PATH}" 110
update-alternatives --install /usr/bin/ex ex "${NVIM_PATH}" 110

The view, vimdiff and ex commands just starts nvim normally, instead of respectively read-only, diff, and ex mode.

Why is nvim reacting differently than vim ? How should we do to keep the update-alternatives integration in Debian/Ubuntu ?

like image 839
Pivert Avatar asked Oct 26 '25 13:10

Pivert


1 Answers

update-alternatives --install /usr/bin/editor editor /usr/bin/vi 10
update-alternatives --install /usr/bin/editor editor /usr/bin/vim 20
update-alternatives --install /usr/bin/editor editor /usr/local/bin/nvim 30
update-alternatives --install /usr/bin/editor editor /usr/bin/view 40
update-alternatives --install /usr/bin/editor editor /usr/bin/vimdiff 50
update-alternatives --install /usr/bin/editor editor /usr/bin/ex 60

Set the High priority for the preferred editor.

like image 158
GAD3R Avatar answered Oct 29 '25 06:10

GAD3R