Skip to content

Instantly share code, notes, and snippets.

@countvajhula
countvajhula / vim-normal-grammar.md
Last active April 20, 2022 00:49
A Grammar for Vim's Normal Mode

A Grammar for Vim's Normal Mode

A rough attempt at characterizing Vim's Normal Mode grammar that I made while writing this Vim series. See the bibliography there for more context.

Notation: | means or, [] means optional, * means zero or more, <> means literal class (e.g. <number> could expand to 1, 2, etc.), ... means there are more instances not enumerated here (these would need to be fleshed out to get a complete grammar).

It could be interesting to use a grammar like this one to organize an interactive Vim cheatsheet.

normal-command = motion-form

| verb-phrase

@necessary129
necessary129 / [email protected]
Last active November 23, 2021 20:52
Systemd service for synapse workers
[Unit]
Description=Matrix Synapse Worker %i
PartOf=matrix-synapse.service
[Service]
Type=simple
ExecStart=/usr/bin/python -B /path/to/synapse_worker.py -c /etc/matrix-synapse/homeserver.yaml -c /etc/matrix-synapse/conf.d/ -c /etc/matrix-synapse/workers/common.yaml -c /etc/matrix-synapse/workers/%i.yaml
User=matrix-synapse
WorkingDirectory=/var/lib/matrix-synapse
EnvironmentFile=/etc/default/matrix-synapse
@romainl
romainl / pseudo-text-objects.md
Last active March 3, 2025 06:04
Custom pseudo-text objects

This is a list of custom pseudo-text objects for Vim.

Note the use of "pseudo", here. Conceptually, text object are "special" motions but there is no proper mechanism dedicated to creating text objects, specifically. We are left with the generic mechanism succinctly described under the easy-to-miss :help omap-info.

Writing one's own pseudo-text objects and motions is a great way to extend Vim without perverting its nature ;-).


My Vim-related gists.

@romainl
romainl / Vim_pushing_built-in_features_beyond_their_limits.markdown
Last active June 25, 2025 10:55
Vim: pushing built-in features beyond their limits

Vim: pushing built-in features beyond their limits

The situation

Searching can be an efficient way to navigate the current buffer.

The first search commands we learn are usually / and ?. These are seriously cool, especially with the incsearch option enabled which lets us keep typing to refine our search pattern. / and ? really shine when all we want is to jump to something we already have our eyeballs on but they are not fit for every situation:

  • when we want to search something that's not directly there, those two commands can make us lose context very quickly,
  • when we need to compare the matches.
@Bad-ptr
Bad-ptr / helm-persp-bridge-v2.el
Last active August 8, 2024 06:36
persp-mode stuff
(with-eval-after-load "persp-mode"
(with-eval-after-load "helm-mode"
(defvar helm-mini-tail-sources (cdr helm-mini-default-sources))
(defvar helm-persp-completing-read-handlers
'((switch-to-buffer . helm-persp-buffer-list-bridge)
(kill-buffer . helm-persp-buffer-list-bridge)
(persp-kill-buffer . helm-persp-buffer-list-bridge)
(persp-temporarily-display-buffer . helm-persp-buffer-list-bridge)
(persp-add-buffer . helm-persp-buffer-list-bridge)
@azadkuh
azadkuh / vim-cheatsheet.md
Last active December 4, 2025 06:28
vim / vimdiff cheatsheet - essential commands

Vim cheat sheet

Starting Vim

vim [file1] [file2] ...

@chantastic
chantastic / on-jsx.markdown
Last active November 28, 2025 06:34
JSX, a year in

Hi Nicholas,

I saw you tweet about JSX yesterday. It seemed like the discussion devolved pretty quickly but I wanted to share our experience over the last year. I understand your concerns. I've made similar remarks about JSX. When we started using it Planning Center, I led the charge to write React without it. I don't imagine I'd have much to say that you haven't considered but, if it's helpful, here's a pattern that changed my opinion:

The idea that "React is the V in MVC" is disingenuous. It's a good pitch but, for many of us, it feels like in invitation to repeat our history of coupled views. In practice, React is the V and the C. Dan Abramov describes the division as Smart and Dumb Components. At our office, we call them stateless and container components (view-controllers if we're Flux). The idea is pretty simple: components can't

@romainl
romainl / gist:1f93db9dc976ba851bbb
Last active November 13, 2024 12:03
Vim: available key pairs in normal mode…

Vim: available key pairs in normal mode

All lowercase

The operators c, d, and y expect a motion, like w, e, etc. The second character in the following pairs is not a motion so it is a NOP and nothing is overridden if we use them in mappings.

cd cm co cp cq cr cs cu cx cy cz

dc dm dq dr ds du dx dy dz

Download the inspect-registers.vim file from this gist. Open the file in Vim, launching with no vimrc:

vim -Nu NONE inspect-registers.vim

Source the file:

:source %

Insert text on line one: