Skip to content

Instantly share code, notes, and snippets.

@kylechui
kylechui / dot-repeating.md
Last active December 7, 2024 13:42
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

@jinschoi
jinschoi / create_sub.py
Last active November 11, 2024 19:05
Python script to generate Flipper RAW .sub files from OOK bitstreams
#!/usr/bin/env python3
from typing import Iterable, Union, Any
# freq: frequency in Hz
# zerolen: length of space bit in μs
# onelen: length of mark bit in μs
# repeats: number of times to repeat sequence
# pause: time to wait in μs between sequences
# bits: string of ones and zeros to represent sequence
@EgZvor
EgZvor / smooth_split.vim
Created December 9, 2021 14:36
Smooth window splitting animation for Vim
function SmoothSplit(vertical = 0) abort
syntax off
if a:vertical
let new_size = winwidth(0) / 2
vertical 1 split
else
let new_size = winheight(0) / 2
1 split
endif
if a:vertical
@EgZvor
EgZvor / jumpfile.vim
Created November 8, 2021 18:22
Vim mappings to jump through jumplist by files
if exists('g:loaded_jumpfile')
finish
endif
let g:loaded_jumpfile = 1
function! JumpFileComputePrevious()
let [jump_list, pos] = getjumplist()
let previous_list = jump_list
\ ->map({idx, val -> [idx, val]})[:pos]

"better" gx for vim

Vim has built-in gx mapping to open an URL under the cursor defined in the bundled netrw plugin. It is limited to barebone urls and quite often that is not enough.

I have come up with a better gx mapping (for me of course) that is able to open:

  • markdown links [Hacker news](https://news.ycombinator.com 'link to Hacker news website');

  • asciidoc links https://news.ycombinator.com[Hacker news];

@EgZvor
EgZvor / vims.sh
Last active August 17, 2021 17:45
#!/bin/bash
if [ "$1" == "--servername" ]; then
servername="$2"
shift 2
else
servername=$(vim --serverlist | rofi -dmenu -i -p "Enter the vim server name" 2>/dev/null)
fi
if [ "${servername}" == "" ]; then

Simple Templates In Vim

Vim has :h skeleton help topic for when you want to read a skeleton (template) file into a new file.

For me the idea of automatic templates is not that appealing, instead I would rather insert a template when I need it:

:r ~/.vim/asciidoctor/template_for_entity_relation_diagram

@jonpulsifer
jonpulsifer / toggle-virtualization.bat
Last active September 25, 2024 16:11
Virtualization must be disabled to use CS:GO anti-cheat clients like FACEIT and ESEA, but I like to use WSL2 and Docker, and this script helps me do that
@echo off
echo Virtualization must be disabled to use anti-cheat clients like FACEIT and ESEA
echo.
net session >nul 2>&1
if %ERRORLEVEL% EQU 0 goto :chchchchoices
echo This script requires elevated privileges. Re-run as Administrator to continue
goto :exit
:chchchchoices
@FreddieOliveira
FreddieOliveira / docker.md
Last active December 21, 2024 15:53
This tutorial shows how to run docker natively on Android, without VMs and chroot.

Docker on Android 🐋📱

Edit 🎉

All packages, except for Tini have been added to termux-root. To install them, simply pkg install root-repo && pkg install docker. This will install the whole docker suite, left only Tini to be compiled manually.


Summary