Skip to content

Instantly share code, notes, and snippets.

View ubaldot's full-sized avatar

ubaldot ubaldot

View GitHub Profile
@ubaldot
ubaldot / same_gvim_instance.md
Last active June 1, 2025 09:34
How to re-use a running GVim instance when double-clicking on a text file.

In my daily work, I frequently switch between various applications like web browsers, email clients, messaging apps, and presentation tools — all of which require mouse interaction. Because of this, I no longer use GVim as a full IDE but rather for its original purpose: a powerful text editor.

Within this workflow, it's quite common to double-click a file to open it. However, I've noticed that doing so with text files launches a new instance of GVim each time. This not only slows things down, as the vimrc is reloaded with every launch, but also clutters my workspace with multiple GVim windows. The ideal behavior would be to reuse an existing GVim instance when opening files, avoiding repeated vimrc reloads and improving responsiveness.

Fortunately, I found a solution using GVim’s built-in server-client feature, which I’ll explain next.

@ubaldot
ubaldot / visual_surround.vim
Last active August 18, 2024 22:03
Markdown and Vim: quick Bold, italic and strikethough toggle.
def Surround(pre: string, post: string)
var pre_len = strlen(pre)
var post_len = strlen(post)
var [line_start, column_start] = getpos("'<")[1 : 2]
var [line_end, column_end] = getpos("'>")[1 : 2]
if line_start > line_end
var tmp = line_start
line_start = line_end
line_end = tmp