snipt

Ctrl+h for KB shortcuts

VimL

Sort by line length in vim

:%s/.*/\=printf("%03d", len(submatch(0)))."|".submatch(0)/ |sor n|
https://snippets.siftie.com/embed/a4ef05ccf477e90c082095a889ac6876/
/raw/a4ef05ccf477e90c082095a889ac6876/
a4ef05ccf477e90c082095a889ac6876
vim
VimL
1
2019-04-22T22:18:32
True
False
False
/api/public/snipt/27081/
sort-by-line-length-in-vim
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="p">:</span>%s<span class="sr">/.*/</span>\<span class="p">=</span>printf<span class="p">(</span><span class="s2">&quot;%03d&quot;</span><span class="p">,</span> len<span class="p">(</span>submatch<span class="p">(</span><span class="m">0</span><span class="p">)))</span>.<span class="s2">&quot;|&quot;</span>.submatch<span class="p">(</span><span class="m">0</span><span class="p">)</span>/ <span class="p">|</span><span class="k">sor</span> <span class="k">n</span><span class="p">|</span> </span></pre></div> </td></tr></table>
vim