Skip to content

Instantly share code, notes, and snippets.

View vtvz's full-sized avatar
🦊
What does DevOps say

Vitaly Zaslavsky vtvz

🦊
What does DevOps say
View GitHub Profile
@kylechui
kylechui / dot-repeating.md
Last active July 29, 2024 07:58
A basic overview of how to manage dot-repeating in your Neovim plugin, as well as manipulate it to "force" what action is repeated.

Adding dot-repeat to your Neovim plugin

In Neovim, the . character repeats "the most recent action"; however, this is not always respected by plugin actions. Here we will explore how to build dot-repeat support directly into your plugin, bypassing the requirement of dependencies like repeat.vim.

The Basics

When some buffer-modifying action is performed, Neovim implicitly remembers the operator (e.g. d), motion (e.g. iw), and some other miscellaneous information. When the dot-repeat command is called, Neovim repeats that operator-motion combination. For example, if we type ci"text<Esc>, then we replace the inner contents of some double quotes with text, i.e. "hello world""text". Dot-repeating from here will do the same, i.e. "more samples""text".

Using operatorfunc

@paulrobertlloyd
paulrobertlloyd / figure.html
Created January 9, 2015 21:26
Custom Liquid tag block to render a figure with optional caption
<!-- Arguments without quotes -->
<!-- ISSUE: Only content between first two quotes rendered -->
<figure class="figure class1"><div class="figure__main">
<p><img src="/assets/images/2008/12/chicago.jpg" alt="" /></p>
</div><figcaption class="figure__caption"><p>Cloud&nbsp;Gate</p>
</figcaption></figure>
<!-- Arguments with single quotes, regardless of content -->
<!-- ISSUE: Nothing generated if argument contains quotes -->
<figure class="figure class1 class2"><div class="figure__main">