My Gemini Editing Setup with Vim
Since Gemini is line-oriented, it means a lot of my usual tricks for editing markdown-like code don't work like I'm used to them working.
But I *love* Vim and use it for everything, so I'd like to get it into some kind of working order for Gemini. My first thought was that it couldn't do it and I'd have to try something else. My second, more sensible thought was that Vim has been around forever and there are options for virtually everything and surely it's possible to set this up.
ChatGPT was of great assistance in helping identify the options I wanted.
The Changes
Notably, when I edit text, I automatically break lines at 72 columns. But Gemini clients tend to render those hard returns in inconvenient places. So I want to turn off that feature.
No problem:
:set textwidth=0
No more automatic newline insertions.
But this makes single lines get really long, and I have it set up to scroll off to the right with `nowrap`. So let's turn that back on.
:set wrap
Looking better! But that's an ugly place to break the line, just hard at the edge of the screen. Luckily there's a way to make Vim break on whitespace instead:
:set linebreak
And that looks better, still!
Annoyingly, though, each paragraph is still a single "line" from Vim's perspective. This means when I move up or down with `j` or `k` (or the arrow keys), it moves up or down an entire paragraph instead of a single line.
Vim does have keystrokes that go up only a visual line: `gk` for up and `gj` for down. So I can just use those. Or, since that's a bit of a pain, we can remap the arrow keys and `j` and `k` to just do that instead. The following does that for all combinations of arrow keys, `j`, and `k` in both visual and normal mode:
:nnoremapgk :vnoremap gk :nnoremap k gk :vnoremap k gk :nnoremap gj :vnoremap gj :nnoremap j gj :vnoremap j gj
And with that the cursor up/down keys work with least surprise.
Usage
I saved all those commands in a file and then I set up a shell alias to read them (after Vim reads in the normal `.vimrc`).
$ alias vig='vim -S ~/path_to/gemini.vimrc'
And now when I edit a Gemini file I just remember to do it using `vig` so that config is read in.
Going forward, I might lose the alias and modify the `.vimrc` to always run these commands for every Gemini file (`FileType` is `gemtext`) but I want to make sure I'm happy with it in all circumstances first.
My Complete Vim RC File for Gemini
" This is setting up Vim for Gemini file editing " " alias vig='vim -S ~/path_to/gemini.vimrc' set nonumber set wrap set linebreak set tw=0 nnoremapgk vnoremap gk nnoremap k gk vnoremap k gk nnoremap gj vnoremap gj nnoremap j gj vnoremap j gj
───────────