Short one parroting someone else’s post. I use Vim as my go-to editor everywhere (though these days it is Neovim more often than not). I want to easily use it when I double-click to open a file. I also do not want to install and try out a bunch of different GUI interfaces, just give me my editor in a terminal.
Opening Files with Kitty
Seems this is easily done with the Kitty terminal emulator installed, just set
your file to be opened by Kitty (Right click→Get Info, change all), ensure your
$EDITOR environment variable is set, and Kitty will handle the rest. I am
actually an Alacritty user, not a Kitty user, but this might be another reason
to fully make the switch.
Telling Kitty How To Handle Your Files
As mentioned, if you
$EDITOR environment variable is set, Kitty will be able
to handle a bunch of files already by default (think
For some files however, you might get a terminal window that immediately closes
again. As far as I can tell this is due to Kitty not knowing what to do with
that particular file. For example, I had this occur with
.yml files and with
Dockerfile files. To fix this, you need Kitty launch actions. While there
seems to be a way to define actions using mime types, this did not seem to work
correctly for these files, so I went more explicit with extensions.
Example of my
protocol file ext yml,fish,lua action launch --type=os-window $EDITOR $FILE_PATH protocol file file Dockerfile action launch --type=os-window $EDITOR $FILE_PATH
Note that it seems to use your
$HOME as the root folder for the (neo)vim
session that starts. So you may want to
:cd into the right folder within vim
if the quick edit turns into a longer session where you want to open more files
within the relevant folder.
Also note that this may have unintended consequences of trying to run your
file. For example, the Kitty default for an
.sh file seems to be execution.
Be wary of this. So setting
.sh to be opened by Kitty without overriding the
behaviour might make you execute files you did not want to execute. You have