Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

Text only

Simple settings for working with vi and js

set nu si fdm=marker foldminlines=5 foldmarker={,} paste pt=<F6> filetype=javascript
https://snipt.net/embed/e11fb162fe871ac118636d9780cc4b4b/
https://snipt.net/raw/e11fb162fe871ac118636d9780cc4b4b/
e11fb162fe871ac118636d9780cc4b4b
text
Text only
1
2016-12-04T00:44:18
True
False
False
/api/public/snipt/28541/
simple-settings-for-vijs
<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>set nu si fdm=marker foldminlines=5 foldmarker={,} paste pt=&lt;F6&gt; filetype=javascript </span></pre></div> </td></tr></table>
vi

Python

Regex for vi, remove all leading whitespace for a file.

%s/^\s\s*//g
https://snipt.net/embed/c012155e366d6d0fb0fbc71939b1a192/
https://snipt.net/raw/c012155e366d6d0fb0fbc71939b1a192/
c012155e366d6d0fb0fbc71939b1a192
python
Python
1
2016-12-04T00:46:05
True
False
False
/api/public/snipt/23650/
regex-for-vi-remove-all-leading-whitespace-for-a-file
<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="o">%</span><span class="n">s</span><span class="o">/^</span>\<span class="n">s</span>\<span class="n">s</span><span class="o">*//</span><span class="n">g</span> </span></pre></div> </td></tr></table>
regex, vi

Text only

sostituzione multipla in vi

:1,$ s/<cosavogliosostituire>/<quelloconcuisostituisco>/g
https://snipt.net/embed/c06ef6532c986c512bb531038c302a91/
https://snipt.net/raw/c06ef6532c986c512bb531038c302a91/
c06ef6532c986c512bb531038c302a91
text
Text only
1
2016-12-04T00:47:28
True
False
False
/api/public/snipt/20177/
sostituzione-multipla-in-vi
<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>:1,$ s/&lt;cosavogliosostituire&gt;/&lt;quelloconcuisostituisco&gt;/g </span></pre></div> </td></tr></table>
bash, vi

Text only

How to write a read-only file in vi if you have sudo root

:w !sudo tee %
https://snipt.net/embed/cf4dcae6a97a0d5ea71ea7e97da96353/
https://snipt.net/raw/cf4dcae6a97a0d5ea71ea7e97da96353/
cf4dcae6a97a0d5ea71ea7e97da96353
text
Text only
1
2016-12-04T00:48:30
True
False
False
/api/public/snipt/20057/
how-to-write-a-read-only-file-in-vi-if-you-have-sudo-root
<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>:w !sudo tee % </span></pre></div> </td></tr></table>
root, sudo, vi, vim

VimL

convert camelCase to underscore in vi

"converte il camelCase in _ nelle righe dalla 1 alla 3
:1,3s/[A-Z]/_\L&/g 
https://snipt.net/embed/e4aa90620e21be386971c4b70bf194cb/
https://snipt.net/raw/e4aa90620e21be386971c4b70bf194cb/
e4aa90620e21be386971c4b70bf194cb
vim
VimL
2
2016-12-04T05:06:36
True
False
False
/api/public/snipt/18367/
convert-camelcase-to-unsercore-in-vi
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c">&quot;converte il camelCase in _ nelle righe dalla 1 alla 3</span> </span><span id="L-2"><a name="L-2"></a><span class="p">:</span><span class="m">1</span><span class="p">,</span><span class="m">3</span>s<span class="sr">/[A-Z]/</span>_\L&amp;/<span class="k">g</span> </span></pre></div> </td></tr></table>
camelcase, unserscore, vi, vim

Bash

Save a file edited in VIm without the needed permissions

:w !sudo tee %
https://snipt.net/embed/977e761186085986860c3e05cbae35dc/
https://snipt.net/raw/977e761186085986860c3e05cbae35dc/
977e761186085986860c3e05cbae35dc
bash
Bash
1
2016-12-04T00:49:44
True
False
False
/api/public/snipt/14357/
save-a-file-edited-in-vim-without-the-needed-permissions
<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>:w !sudo tee % </span></pre></div> </td></tr></table>
bash, vi, vim

Bash

remove newline chars in vi

1
2
3
:%s/^v<Carriage Return>//g

*hit the ctrl key + v then hit the carriage return.
https://snipt.net/embed/93b41e5ce27ed4ee81eb0f59144c7974/
https://snipt.net/raw/93b41e5ce27ed4ee81eb0f59144c7974/
93b41e5ce27ed4ee81eb0f59144c7974
bash
Bash
3
2016-12-04T00:50:11
True
False
False
/api/public/snipt/10600/
remove-newline-chars-in-vi
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>:%s/^v&lt;Carriage Return&gt;//g </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>*hit the ctrl key + v <span class="k">then</span> hit the carriage <span class="k">return</span>. </span></pre></div> </td></tr></table>
linux, newline, vi

Text only

vi no auto-indenting etc ...

1
2
3
4
If you disagree with vi´s auto-indenting as much as I do, you can turn it off in vi with:

     :set noai 
     :set noautoindent 
https://snipt.net/embed/23725ae5d860eeb2904561a5ee50f453/
https://snipt.net/raw/23725ae5d860eeb2904561a5ee50f453/
23725ae5d860eeb2904561a5ee50f453
text
Text only
4
2016-12-04T00:50:46
True
False
False
/api/public/snipt/10518/
vi-no-auto-indenting-etc
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>If you disagree with vi´s auto-indenting as much as I do, you can turn it off in vi with: </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a> :set noai </span><span id="L-4"><a name="L-4"></a> :set noautoindent </span></pre></div> </td></tr></table>
..., auto-indenting, etc, no, vi
Copyrighted, illegal, or inappropriate content? Email [email protected].