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
vimを読もうとした話
Search
Hakkadaikon
December 13, 2023
390
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
vimを読もうとした話
ゴリラ.vim #29 登壇時のスライド。
https://gorillavim.connpass.com/event/301953/
Hakkadaikon
December 13, 2023
Transcript
31 slides
を 読もうとした話 ゴリラ.VIM #29 発火大根
自己紹介 名前 : 発火大根 職業 : インフラエンジニア (コードも書くよ) vim歴 :
6-7年? (プラグイン等に凝りだして2年半くらい)
最近は技術書典でNostrやBluesky (SNS)の本出したり オンライン勉強会配信やったりしてます
ハイブリッド勉強会も! 12/8(金)開催しました!
今日は… vimを読もうとした話をします
なぜ読もうと思ったか? ・vimにいつかコントリビュートしたい ・いつも使っているvimがどう作られているか知りたい
唐突にクイズ! vimリポジトリのソースコードは何行あると 思いますか? ・src/以下をclocコマンドで計測 ・11/27時点の実行行数(空行/コメントを除く)とする
答え 836,105行
多い!
ちょっと待とう まあ、落ち着いてエントリポイントから読んでみよう -> src/以下にmain.cがある!
None
main.cだけで 中々のボリューム。
MAIN.Cのソース(一部)
VIMのソースをそのまま読むのは大変 ・main.cだけでもボリュームが多い ・ifdefが多い ・インデントが揃っていない場合も
そこで、、、 ①main.cを整形 ②エントリポイント抜き出し ③ifdefを除く ④皆大好きChatGPTに説明させる
①main.cを整形 clang-formatで 自分好みに インデントを整形!
②エントリポイント抜き出し 実はエントリポイントだけだと、そこまで行数無い (99L~443L) = 345L
③ifdefを除く 「unifdef」というコマンドがある ->プロセッサ条件行を取り除ける
③ifdefを除く vimをビルド時のログをリダイレクト $ make > make.log
③ifdefを除く リダイレクト結果から、「-D」を取り出す gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -pthread -I/usr/include/gtk-3.0
- I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 - I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio- unix-2.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/fribidi - I/usr/include/harfbuzz -I/usr/include/atk-1.0 -I/usr/include/cairo - I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 - I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount - I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib- 2.0/include -O2 -fno-strength-reduce -Wall -Wno-deprecated-declarations -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -o objects/main.o main.c
③ifdefを除く main.cから#if/#ifdef/#ifndefを取り出す $cat main.c | grep -e “#if” -e “#elif”
-e “defined”
③ifdefを除く unifdefでifdefを取り除く $ unifdef ¥ -D[定義1] -D[定義2] … ¥ -U[定義1]
-U[定義2] … ¥ main.c
③ifdefを除く 150行くらいのエントリポイントが抽出できた!
④ChatGPTに聞く GPT-4の力を借りる
④ChatGPTに聞く いい感じの回答をゲッツ!
④ChatGPTに聞く GPT-4のエントリポイント説明 要約すると… ①色々初期化する ②メインループ(vim_main2)実行
④ChatGPTに聞く 同じ要領で、vim_main2もGPT-4に説明させた。
④ChatGPTに聞く こんな感じで、 GPT-4でmainから追って概要説明させていけば 普通に読むより相当楽なはず! ※AIの性質上、たまに嘘吐かれるのでそこは注意
という話でした。
え、vim本体を解析して解説してくれるんじゃない の!? 宣伝スライド2枚も挟んだのに!? -> 別途、技術記事を作成予定!
おしまい
More Decks by Hakkadaikon
See All by Hakkadaikon
高橋メソッドでCVE解説シリーズ 〜CVE-2026-99999〜
hakkadaikon
0
36
高橋メソッドでCVE解説シリーズ 〜CVE-2026-98432〜
hakkadaikon
0
36
高橋メソッドでCVE解説シリーズ 〜CVE-2026-112816〜
hakkadaikon
0
260
MoQTフルスクラッチ実装
hakkadaikon
1
120
Just do it ! で 走り抜けてきたけど ちょっと立ち止まってみた
hakkadaikon
0
950
自作WebSocket (RFC6455)
hakkadaikon
0
170
routstrについて
hakkadaikon
0
190
Nostr x BTC
hakkadaikon
0
84
Blueskyのプラグインを作ってみた
hakkadaikon
1
910
Featured
See All Featured
A designer walks into a library…
pauljervisheath
211
25k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.5k
A Modern Web Designer's Workflow
chriscoyier
699
190k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
330
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
670
エンジニアに許された特別な時間の終わり
watany
109
250k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
560
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
1
240
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
1.1k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
22k
Design in an AI World
tapps
1
390