3

While trying to make vim default instead of gedit, I found this could be done two ways:

  1. Use defaults.list and make text/plain (and others) point to vim.desktop (what is the format for creating .desktop files?)

  2. Use update-alternatives and change gnome-text-editor (right now it has only one alternative, so I guess I have to install one more. How to do that?)

Which is the better way to do it?

8
  • how do you want to launch (g)vim? command line? clicking a icon?
    – akira
    Apr 8, 2011 at 6:46
  • @akira: If I click a text file, vim should open in a terminal.
    – N 1.1
    Apr 8, 2011 at 6:50
  • 1
    any objections against gvim?
    – akira
    Apr 8, 2011 at 6:52
  • @akira 1. I don't have it installed, 2. Why not vim?
    – N 1.1
    Apr 8, 2011 at 6:56
  • @N 1.1: coz you have to associate something like 'xterm -e vim ' with the extension you want to use. vim is a terminal application (it has no 'window').
    – akira
    Apr 8, 2011 at 7:00

3 Answers 3

4

There is a command

select-editor

That is for the user. Globally You can use update-alternatives to set editor to vim

1
  • 1
    If your editor isn't on the list, do this first (for geany) update-alternatives --install /usr/bin/editor editor /usr/bin/geany 10
    – PJ Brunet
    Feb 6, 2015 at 5:24
1

Ok, I have created vim.desktop in ~/.local/share/applications and modified defaults.list (in the same dir) to include

text/plain=vim.desktop

After that, sudo update-mime and its working! (I am not sure whether this step is require)

Clicking on a text file opens vim, not gvim, in terminal and :q closes the terminal too.

p.s. there are many *.desktop in the mentioned folder, copy the necessary key=values from them and create vim.desktop

-2

When you install the vim packages one of those change the default editor for you. I think it's the gvim package that fixes your problem.

aptitude install vim vim-scripts vim-doc vim-gui-common vim-gnome

And the most common way to use vim is that if you start it from X you start gvim, and if you are in a terminal you start vim.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .