Published on

Editing Remote Files with Kitty Terminal

Authors
  • avatar
    Name
    Kiet
    Twitter

When using ssh to connect to a remote server, I often need to edit files. In such cases, I usually use vim to make the necessary changes. While using vim without a custom config isn’t a big deal for me, I still prefer to use nvim with my own configuration.

There are many ways to approach this. I could fetch my dotfiles and set up nvim with my config on the server, but I don’t want to confuse my colleagues, as they don’t use vim or nvim at all.

Then I discovered the built-in remote file editing feature in the Kitty terminal, and it’s fantastic.

First, you need to configure your preferred editor for remote file editing. To find out which version of your editor is used on your system, run the which command to get its path. For example, with nvim:

which nvim
Which nvim

Next, add this line to your Kitty terminal settings:

editor /opt/homebrew/bin/nvim

Once you’ve set that up, connect to your remote server and give it a try.

Run the following command to list the directory contents with hyperlinks:

ls --hyperlink=auto
List files with hyperlink

Hold down Ctrl + Shift and click on a filename to bring up the remote file actions menu.

Remote file actions

Press E, and the remote file will be downloaded and opened with your local editor:

Edit with local nvim

Now, you can modify the file and save it. After saving, the file will automatically be uploaded back to the remote server.

Edit finish

Finally, you can verify the edited file’s content on the remote server using cat:

Result