Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

Text only

sudo inside of VIM

:w ! sudo tee %
https://snipt.net/embed/c2234aa3e2e568a360fe44c2d5ef1b49/
https://snipt.net/raw/c2234aa3e2e568a360fe44c2d5ef1b49/
c2234aa3e2e568a360fe44c2d5ef1b49
text
Text only
1
2016-12-02T13:03:03
True
False
False
/api/public/snipt/84521/
sudo-inside-of-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>:w ! sudo tee % </span></pre></div> </td></tr></table>
Debian, Linux, Ubuntu, sudo, vim

Text only

Select a Block of Text in Visual Mode

1
2
3
4
5
6
7
# To select a block of text from line xx to line yy
# On line xx
ma

# On line yy
Shift + v
`a
https://snipt.net/embed/692622a64b09582415ea5853cab66a51/
https://snipt.net/raw/692622a64b09582415ea5853cab66a51/
692622a64b09582415ea5853cab66a51
text
Text only
7
2016-12-02T13:03:06
True
False
False
May 07, 2013 at 10:48 PM
/api/public/snipt/60891/
select-a-block-of-text-in-visual-mode
<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> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a># To select a block of text from line xx to line yy </span><span id="L-2"><a name="L-2"></a># On line xx </span><span id="L-3"><a name="L-3"></a>ma </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a># On line yy </span><span id="L-6"><a name="L-6"></a>Shift + v </span><span id="L-7"><a name="L-7"></a>`a </span></pre></div> </td></tr></table>
vim

VimL

Auto-incrementing pattern match

let g:I=1
%g/^- id: \d\+$/ s/\d\+/\=g:I/|let g:I=g:I+1
https://snipt.net/embed/e7c3d2a3be4f428a198dbf003a98641c/
https://snipt.net/raw/e7c3d2a3be4f428a198dbf003a98641c/
e7c3d2a3be4f428a198dbf003a98641c
vim
VimL
2
2016-12-02T13:03:14
True
False
False
Mar 30, 2013 at 08:47 PM
/api/public/snipt/58583/
auto-incrementing-pattern-match
<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="k">let</span> <span class="k">g</span>:I<span class="p">=</span><span class="m">1</span> </span><span id="L-2"><a name="L-2"></a>%<span class="k">g</span><span class="sr">/^- id: \d\+$/</span> s<span class="sr">/\d\+/</span>\<span class="p">=</span><span class="k">g</span>:I/<span class="p">|</span><span class="k">let</span> <span class="k">g</span>:I<span class="p">=</span><span class="k">g</span>:I<span class="p">+</span><span class="m">1</span> </span></pre></div> </td></tr></table>
pattern, vim

Text only

Remove numeration line on vi / vim

Press esc
:set nu!
https://snipt.net/embed/ba448381b651ef69c2dc2a65f1a504d1/
https://snipt.net/raw/ba448381b651ef69c2dc2a65f1a504d1/
ba448381b651ef69c2dc2a65f1a504d1
text
Text only
2
2016-12-02T13:03:22
True
False
False
/api/public/snipt/52420/
remove-numeration-line-on-vi-vim
<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>Press esc </span><span id="L-2"><a name="L-2"></a>:set nu! </span></pre></div> </td></tr></table>
vim

VimL

Regex find until next Quote

:job_title => "(.*?)", 
#this would match all instances of :job_title => "blah blah"
https://snipt.net/embed/159e33f89abcf85636b46db7477f32a6/
https://snipt.net/raw/159e33f89abcf85636b46db7477f32a6/
159e33f89abcf85636b46db7477f32a6
vim
VimL
2
2016-12-02T06:52:31
True
False
False
Nov 26, 2012 at 06:45 PM
/api/public/snipt/50790/
regex-find-until-next-quote
<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="p">:</span>job_title <span class="p">=&gt;</span> <span class="s2">&quot;(.*?)&quot;</span><span class="p">,</span> </span><span id="L-2"><a name="L-2"></a>#this would <span class="k">match</span> <span class="k">all</span> instances of :job_title <span class="p">=&gt;</span> <span class="s2">&quot;blah blah&quot;</span> </span></pre></div> </td></tr></table>
regex, vim

Bash

Vim and Git

# view file on another branch in vim
git show <branch>:<file> | vim -
https://snipt.net/embed/01697e1aa03418fb11884c74e41f42b0/
https://snipt.net/raw/01697e1aa03418fb11884c74e41f42b0/
01697e1aa03418fb11884c74e41f42b0
bash
Bash
2
2016-12-02T13:03:28
True
False
False
Nov 10, 2012 at 04:54 PM
/api/public/snipt/49967/
vim-and-git
<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="c1"># view file on another branch in vim</span> </span><span id="L-2"><a name="L-2"></a>git show &lt;branch&gt;:&lt;file&gt; <span class="p">|</span> vim - </span></pre></div> </td></tr></table>
git, vim

Text only

Reformat paragraph text to wrap properly, using fmt command

Select text (using v)
:!fmt
https://snipt.net/embed/1120714594ba9f44ee15f2795862d76a/
https://snipt.net/raw/1120714594ba9f44ee15f2795862d76a/
1120714594ba9f44ee15f2795862d76a
text
Text only
2
2016-12-02T13:03:31
True
False
False
/api/public/snipt/40733/
reformat-paragraph-text-to-wrap-properly-using-fmt-command
<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>Select text (using v) </span><span id="L-2"><a name="L-2"></a>:!fmt </span></pre></div> </td></tr></table>
Linux, fmt, latex, vim
Copyrighted, illegal, or inappropriate content? Email [email protected].