Skip to content

Instantly share code, notes, and snippets.

I'm seeing how far I can get through Advent of Code using only Vim's editing commands. No Vimscript, variables, or function calls allowed! (Use of the expression register is also STRICTLY limited. I employed it to do adding in some early solutions, but anything more complex is a no-no.)

Solutions are notated using the standard notation used in Vim mappings and documentation. Ctrl-A is notated as <C-A>, Escape as <Esc>, Return as <CR>, etc.

But if a line starts with a colon, then it's an entire ex command: press Enter at the end of the line.

Otherwise, linebreaks aren't meaningful: they're just inserted at places that felt "natural" to me.

Note that I'm well aware the same techniques could be streamlined considerably: my intention with these is — hard as this may be to believe — to aim for clarity over efficiency. I'm not golfing here!

@sedm0784
sedm0784 / split-toggle.vim
Last active November 21, 2023 00:16
Split Toggle
nnoremap <Leader>s <Cmd>call SplitToggle()<CR>
command SplitToggle call SplitToggle()
function! SplitToggle() abort
" Check if there's already a split
if !exists('s:split_id')
" Create the split
vsplit
" Move to the new window
wincmd p
#!/bin/sh
while read -r line; do
tmux send-keys -t1 "$line" C-M
done
@sedm0784
sedm0784 / _vim_auto_list.markdown
Last active May 29, 2023 15:43
Vim Automatic List Continuation

Vim Auto List Completion

This snippet makes Vim automatically continue/end lists in insert mode, similar to the way word processors do:

  • It automatically adds the bullet/number for the next list item when you press Return at the end of an existing item,
  • When you press Return on an empty list item, it removes the bullet/number, ending the list.

It supports ordered lists with markers like 1. and unordered lists with - markers (because those are the markers I use.)

(It's particularly useful when using an iOS keyboard where punctuation and numerals are slow to access.)

@sedm0784
sedm0784 / vim_find_section.vim
Last active August 29, 2015 13:56
Mappings for leaping between sections
# An edited version of the code for searching for PlaceHolders (^K) from here:
# http://vim.wikia.com/wiki/User:Tlgrok/Form_Feeds_and_Vertical_Tabs
function! <SID>FindSection (forward)
let l:place_holder = nr2char(12) "form feed
let l:flags="W"
if (!a:forward)
let l:flags.="b"
endif
let l:match=search(l:place_holder, l:flags)
@sedm0784
sedm0784 / CapsLockCtrlEscape.ahk
Last active October 22, 2024 02:07
AutoHotkey script to map Caps Lock to Escape when it's pressed on its own and Ctrl when used in combination with another key, à la Steve Losh. Adapted from one that does something similar with the Ctrl Key on the Vim Tips Wiki (http://vim.wikia.com/wiki/Map_caps_lock_to_escape_in_Windows?oldid=32281). (Plus contribs from @randy909 & @mmikeww.)
g_LastCtrlKeyDownTime := 0
g_AbortSendEsc := false
g_ControlRepeatDetected := false
*CapsLock::
if (g_ControlRepeatDetected)
{
return
}
@sedm0784
sedm0784 / practical-ch3.lisp
Created August 12, 2011 14:29
Pratical: A Simple Database
(defun make-cd (title artist rating ripped)
(list :title title :artist artist :rating rating :ripped ripped))
(defvar *db* nil)
(defun add-record (cd) (push cd *db*))
(defun dump-db ()
(dolist (cd *db*)
(format t "~{~a:~10t~a~%~}~%" cd)))
require 'formula'
class Tads2Compiler <Formula
url 'http://www.tads.org/frobtads/frobtads-t2compiler-0.13.tar.gz'
md5 '12caf94d9c1e646ae04b44da0df83a30'
end
class Tads3Compiler <Formula
url 'http://www.tads.org/frobtads/frobtads-t3compiler-0.13.tar.gz'
md5 '231d359f389be3d28e8134a2b832dd70'
@sedm0784
sedm0784 / sedm0784-quix.txt
Created August 20, 2010 13:26
Quix commands
> Richie's Custom Quix Commands
> TITLE: sedm0784-quix.txt
> REMARKS: Hello, world. Under construction. Dilute! Dilute!
> GITHUB: http://gist.github.com/
> MORE: http://quixapp.com
> UPDATED: 2010-08-20
@Richie's Custom Quix Commands
rl javascript:function%20iprl5(){var%20d=document,z=d.createElement('scr'+'ipt'),b=d.body;try{if(!b)throw(0);d.title='(Saving...)%20'+d.title;z.setAttribute('src','http://www.instapaper.com/j/78TgmhXbGcGu?u='+encodeURIComponent(d.location.href)+'&t='+(new%20Date().getTime()));b.appendChild(z);}catch(e){alert('Please%20wait%20until%20the%20page%20has%20loaded.');}}iprl5();void(0) Read Later
wl javascript:%20(function(){var%20a=document.createElement("script"),b=document.createElement("script"),c=new%20Date(),c=c.getDate();b.src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js";b.type="text/javascript";a.src="http://wacchen.com/javascripts/bookmarklette_min.js?date="+c;a.type="text/javascript";document.body.appendChild(b);document.body.appendChild(a);})(); Watch Lat