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 / matrix-synapse@.service
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.vim
Last active January 11, 2024 07:45
Custom pseudo-text objects
" 24 simple pseudo-text objects
" -----------------------------
" i_ i. i: i, i; i| i/ i\ i* i+ i- i#
" a_ a. a: a, a; a| a/ a\ a* a+ a- a#
" can take a count: 2i: 3a/
for char in [ '_', '.', ':', ',', ';', '<bar>', '/', '<bslash>', '*', '+', '-', '#' ]
execute "xnoremap i" . char . " :<C-u>execute 'normal! ' . v:count1 . 'T" . char . "v' . (v:count1 + (v:count1 - 1)) . 't" . char . "'<CR>"
execute "onoremap i" . char . " :normal vi" . char . "<CR>"
execute "xnoremap a" . char . " :<C-u>execute 'normal! ' . v:count1 . 'F" . char . "v' . (v:count1 + (v:count1 - 1)) . 'f" . char . "'<CR>"
execute "onoremap a" . char . " :normal va" . char . "<CR>"
@romainl
romainl / Vim_pushing_built-in_features_beyond_their_limits.markdown
Last active September 19, 2023 08:16
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 June 29, 2024 14:50
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 July 10, 2024 18:27
vim / vimdiff cheatsheet - essential commands

Vim cheat sheet

Starting Vim

vim [file1] [file2] ...

@chantastic
chantastic / on-jsx.markdown
Last active May 30, 2024 13:11
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 June 16, 2024 20:15
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: