Last active
October 24, 2021 01:57
-
-
Save erdg/24e53ad4fcc71d08c88a432c2bcc6544 to your computer and use it in GitHub Desktop.
Code comment extension for 'VIP' editor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Easy code comments for 'VIP' editor | |
# | |
# In normal mode... | |
# | |
# gca - (go comment after) | |
# starts a comment two spaces past the current end of line. | |
# | |
# gcd - (go comment delete) | |
# deletes comment on line matching ' # ...' format. | |
# | |
# [N]gci - (go comment insert) | |
# inserts '#' in front of first non-blank character of line and | |
# down N lines total. useful for commenting out blocks of code. | |
# | |
# [N]gcu - (go comment unsert / undo) | |
# turn code on again. execute from first line of block. | |
# | |
# BUG - don't use 'gci' or 'gcu' on top-level forms | |
# NOTE - very easy to type in dvorak, possibly annoying in qwerty | |
# In '@lib/vip.l' | |
# | |
# ... | |
# ... | |
# | |
### VIP Entry Point ### | |
# (de vi (Lst) | |
# ... | |
# (case (getch) | |
# ("0" ...) | |
# ... | |
# ("g" | |
# (case (getch) | |
# PASTE HERE | |
("c" | |
(case (getch) | |
("a" # [gca] Append comment to end of line | |
(do 2 | |
(goto | |
(inc (length (get (: buffer text) (: posY)))) | |
(: posY) | |
T ) | |
(insChar " " 1) ) | |
(goto | |
(inc (length (get (: buffer text) (: posY)))) | |
(: posY) | |
T ) | |
(insChar "#" 1) | |
(when (get (: buffer text) (: posY) 1) | |
(inc (:: posX)) ) | |
(when (insMode 1) | |
(setq *Repeat (list 'paste (lit @) T)) ) ) | |
("d" # [gcd] Delete comment from end of line | |
(move 'goRight T) | |
(setq *Search '((L) (match '(" " " " "#" @) L))) | |
(if *Search | |
(move 'goBackward (lit @) *Cnt) | |
(beep) ) | |
(setq *Change "d") | |
(move 'goRight T) ) | |
("i" # [gci] Comment line(s) | |
(move 'goAbs 1 (: posY)) | |
(move 'goForward 'word 1) | |
(move 'goLeft 1) | |
(insChar "#" 1) | |
(when *Cnt | |
(do (- *Cnt 1) | |
(move 'goDown 1) | |
(insChar "#" 1) ) ) ) | |
("u" # [gcu] Uncomment line(s) | |
(move 'goAbs 1 (: posY)) | |
(move 'goForward 'word 1) | |
(insChar " " 1) | |
(when *Cnt | |
(do (- *Cnt 1) | |
(move 'goDown 1) | |
(insChar " " 1) ) ) ) ) ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment