Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Vimprint - A Vim Keystroke Parser
Search
nelstrom
May 28, 2013
Technology
1.2k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Vimprint - A Vim Keystroke Parser
nelstrom
May 28, 2013
More Decks by nelstrom
See All by nelstrom
Follow my leader
nelstrom
10
2.3k
Modelling State Machines with Ragel
nelstrom
11
25k
When & why you should stay out of visual mode
nelstrom
1
3.8k
Vim - Precision editing at the speed of thought
nelstrom
29
6.1k
This is the problem
nelstrom
1
300
Progressive enhancement - a barrier to progress?
nelstrom
1
670
Other Decks in Technology
See All in Technology
Cognition AI Japan - ウェビナー2_テストQA_運用監視
cogakira
0
140
Claude の新機能を、 出た日に触って社内に届けるまで
rfdnxbro
1
140
日本語に強いオープンな大規模言語モデル「LLM-jp」
odashi
4
970
Rustuna: Rustによる高速なOptuna実装
pfn
PRO
0
160
AIがコードを書く時代に、エンジニアは何で自分の価値を証明するのか / In an era where AI writes code how do engineers prove their value
carta_engineering
3
980
実体験から学ぶ分析エージェントの開発と運⽤
recruitengineers
PRO
8
2.3k
Webの常識が通じないHTMLメールのダークモード
teamlab
PRO
0
110
Running Kotlin + Quarkus with Lambda
nealle
1
1.6k
【Data Engineering Summit2026_登壇資料】医療ビッグデータ×AIエージェントを支えるデータ基盤とハーネスエンジニアリング
jmdc_presentation
0
150
"優秀な誰か"の下位互換にならないために
yut0naga1_fa
1
1.8k
WasmをRustにする
sansantech
PRO
0
230
LambdaWebFunctionsを試してみた / exploring-lambda-web-functions
koukihosaka
0
220
Featured
See All Featured
Optimising Largest Contentful Paint
csswizardry
37
4k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.8k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
260
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
930
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
360
How to Talk to Developers About Accessibility
jct
2
580
AI: The stuff that nobody shows you
jnunemaker
PRO
10
1.2k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
460
KATA
mclloyd
PRO
35
16k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.2k
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
740
Heart Work Chapter 1 - Part 1
lfama
PRO
10
37k
Transcript
VIMPRINT A VIM KEYSTROKE PARSER 28th May, 2013 Drew Neil
@nelstrom
VIMPRINT should... visualize keystrokes in realtime
VIMPRINT should... understand all built-in commands
VIMPRINT should... be extensible
VimSpeak Turns spoken English into keystrokes https://github.com/AshleyF/VimSpeak
None
VimSplain Turns keystrokes into plain English https://github.com/pafcu/Vimsplain
Vimulator Turns live keystrokes into plain English https://github.com/thoughtbot/vimulator
None
VimGolf Logs real keystrokes https://github.com/igrigorik/vimgolf
None
vim -w keystrokes are BUFFERED
None
Parslet 1st attempt at parsing Vim keystrokes
None
class Vimprint < Parslet::Parser rule(:start) { match('[iIaAoOsS]').as(:switch) } rule(:typing) {
match('[^\e]').repeat.as(:typing) } rule(:terminate) { match('\e').as(:escape) } rule(:insertion) { start >> typing >> terminate } root(:insertion) end
gv major stumbling block: switch from Normal mode to Visual
mode and select the last selected text
Ragel 2nd attempt at parsing Vim keystrokes
Ragel state machines can not only recognize byte sequences as
regular expression machines do, but can also execute code at arbitrary points in the recognition of a regular language.
%%{ machine vim_print; action return { fret; } action push_insert_mode
{ fcall insert_mode; } escape = 27; input = (any - escape); motion = [hjklbwe0]; switch = [iIaAsSoO]; insert_mode := ( input* escape @return ); normal_mode := ( motion | switch @push_insert_mode )*; }%%
2 IN 1 insert_mode normal_mode '0', 'b', 'e', 'h', 'j'..'l',
'w' 'A', 'I', 'O', 'S', 'a', 'i', 'o', 's' / push_insert_mode 3 27 / return DEF
action H { @head = p } action T {
@tail = p } action EmitMotion { @events << {motion: strokes} } action EmitSwitch { @events << {switch: strokes} } action EmitInput { @events << {input: strokes} } action EmitEscape { @events << {escape: '<Esc>'} } escape = 27 >H@T @EmitEscape; input = (any - escape) >H@T @EmitInput; motion = [hjklbwe0] >H@T @EmitMotion; switch = [iIaAsSoO] >H@T @EmitSwitch;
class VimParser attr_accessor :head, :tail, :data def initialize(listener) @events =
listener %% write data; end def process(input) @data = input.unpack("c*") eof = @data.length stack = [] %% write init; %% write exec; end def strokes @data[@head..@tail].pack('c*') end end
VimParser.new(recorder = []).process("helihello\e") puts recorder {:motion=>"h"} {:motion=>"e"} {:motion=>"l"} {:switch=>"i"} {:input=>"h"}
{:input=>"e"} {:input=>"l"} {:input=>"l"} {:input=>"o"} {:escape=>"<Esc>"} https://gist.github.com/nelstrom/5663083
FATAL FLAWS with parsing keystrokes
FATAL FLAWS no timestamps <leader>{...}
FATAL FLAWS no document context :s/{pattern}/{string}/c
FATAL FLAWS no filetype detection
HALP! https://github.com/nelstrom/vimprint Vimprint Realtime Vim keystroke visualizer