Skip to content

Instantly share code, notes, and snippets.

@BobToninho
Last active March 12, 2025 19:51
Show Gist options
  • Save BobToninho/970813c956dbda9b137db10ef2eeb55b to your computer and use it in GitHub Desktop.
Save BobToninho/970813c956dbda9b137db10ef2eeb55b to your computer and use it in GitHub Desktop.

Tooling

A list of things to remember about my tools.

vim

Delete all buffers but current one
%bd|e#|bd#
Filter elements in quickfix list

(auto completion works)

:packadd cfilter
:Cfilter /pattern/
Keep the ones that do not match the pattern
:Cfilter! /pattern/
Run all commands contained in file
vim -s file
Run asciidoctor after saving the buffer (or any shell command)
autocmd BufWritePost <file> silent! !asciidoctor %
Format current file with prettier
%!bun x prettier --stdin-filepath file.<extension>
Format current file with prettier (if file is on disk)
!bun x prettier -w '%'
Delete the blank, even lines
:g/^/ if line('.') % 2 == 0 | d | endif

vim motions

  • R

  • g_

  • } jump to the next paragraph

Insert mode

  • Ctrl + h - delete the character before the cursor during insert mode

  • Ctrl + w - delete word before the cursor during insert mode

  • Ctrl + j - add a line break at the cursor position during insert mode

Registers

  • "/p paste last search

  • "%p paste file name

nvim

tmux

  • C-o: rotate panes

  • o: move to pane

  • (: move to previous session

  • ): move to next session

  • L: move to last session

  • tmux attach-session -d: -d detached all other clients attached to this session. Useful when errors happen and you kill the terminal

  • tmux attach-session -x: same as -d but additionally send SIGHUP to kill the parent process of the other client

  • tmux new-session -A: makes new-session behave like attach-session, if the session name passed with -s already exists

  • remain-on-exit: pane option, better set it when needed

  • make 2>&1|tmux splitw -dI &: pipe makeÔÇÖs command stdout in a new split window in tmux

git

Git town

Best use of Git town is:

  • town append when creating new branches

  • town switch for visualizing stacked branches and easily switching among them

  • town rename-branch

Git jump

Open $VISUAL (I think) with the diff loaded in the quickfixlist. Useful for reviews
git jump diff origin/main
Or, run from vim
:cexpr system("git jump --stdout diff origin/main")

latex

Use tectonic ensuring the correct biber/biblatex version
tectonic -Z search-path=$(dirname $(kpsewhich biblatex.sty)) report.tex

zsh

  • fc open an editor and edit your last command

  • r foo=bar run the previous command replacing foo with bar

  • :t modifier in folders to show only the last folder in the path

  • :u modifier that transforms to uppercase

  • :l modifier that transforms to lowercase

  • :s/find/replace modifier that replaces ÔÇ£findÔÇØ with ÔÇ£replaceÔÇØ

pandoc

Convert markdown to txt files
pandoc -f markdown -t plain file.md -o file.txt

shell

How to prompt the user for multiple selections

In bash, the select bultin shall be used. For instance:

select FILE in *; do echo $FILE $REPLY; break; done

Will show a numbered list of all the items inside the current working directory and display the PS3 prompt for choosing one element.

Read more in the docs.

python

Minimal HTTP server
python3 -m http.server 8080 --bind 127.0.0.1 --directory ./

asciidoc

Link a file to another
# OK
link:file.txt[text]
link:file.txt[]

# does NOT work
link:file.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment