Quantcast
Channel: Vimタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 5608

連番展開とかするvim plugin(ネタ)

$
0
0

ネタなのでスルーしてください。

昔作った、プラグインです
[(begin)-(end)]の部分を連番に展開します。ExpandSerialNmuber.vim

こんなのとか
expandserialnum2.gif

素敵な素材画像のDLとか(今気づいたけど、これじゃ上書きされちゃいますね…)
expandserialnum5.gif

後方参照的なこととか、計算もできます(evalに投げてるだけですが)
expandserialnum4.gif

さて、
0-65535に正規化されたSinθを1/1024ステップでの1/4周期分、2進数で表示したいことってよくありますよね!

それ1行でできます!

[substitute(substitute(substitute(substitute(substitute(substitute(substitute(substitute(substitute(substitute(substitute(substitute(substitute(substitute(substitute(substitute(printf("%04x",float2nr(pow(2,16)*sin([0-1023]*0.5*3.141592/1024.0))),"0","0000","g"),"1","0001","g"),"2","0010","g"),"3","0011","g"),"4","0100","g"),"5","0101","g"),"6","0110","g"),"7","0111","g"),"8","1000","g"),"9","1001","g"),"a","1010","g"),"b","1011","g"),"c","1100","g"),"d","1101","g"),"e","1110","g"),"f","1111","g")] 

vimで16進数→2進数の変換が分からなかったのでベタ書きしちゃったw

おわりに

個人的には頻繁に使ってるんですが、欠点はソースコードが酷いこと


Viewing all articles
Browse latest Browse all 5608

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>