snipt

Ctrl+h for KB shortcuts

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/
/raw/692622a64b09582415ea5853cab66a51/
692622a64b09582415ea5853cab66a51
text
Text only
7
2019-07-17T01:18:28
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

Bash

Open a new empty tab

:tabnew
https://snipt.net/embed/380135f9e728a680d640e1db5f29c68a/
/raw/380135f9e728a680d640e1db5f29c68a/
380135f9e728a680d640e1db5f29c68a
bash
Bash
1
2019-07-12T12:15:41
True
False
False
/api/public/snipt/35785/
open-a-new-empty-tab
<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>:tabnew </span></pre></div> </td></tr></table>
vim

Bash

Turn off auto indent when pasting text into vim

1
2
3
4
5
6
7
# Switch to the 'paste' mode
:set paste

# Paste the text

# Turn off the 'paste' mode
:set nopaste
https://snipt.net/embed/744fdaead0084803e913257eab7d47b2/
/raw/744fdaead0084803e913257eab7d47b2/
744fdaead0084803e913257eab7d47b2
bash
Bash
7
2019-07-17T02:09:49
True
False
False
/api/public/snipt/29358/
turn-off-auto-indent-when-pasting-text-into-vim
<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><span class="c1"># Switch to the &#39;paste&#39; mode</span> </span><span id="L-2"><a name="L-2"></a>:set paste </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="c1"># Paste the text</span> </span><span id="L-5"><a name="L-5"></a> </span><span id="L-6"><a name="L-6"></a><span class="c1"># Turn off the &#39;paste&#39; mode</span> </span><span id="L-7"><a name="L-7"></a>:set nopaste </span></pre></div> </td></tr></table>
vim

Bash

Select columns

Ctrl + v
https://snipt.net/embed/8b465d7484f3a7c5c91766f202a014e3/
/raw/8b465d7484f3a7c5c91766f202a014e3/
8b465d7484f3a7c5c91766f202a014e3
bash
Bash
1
2019-06-26T20:12:08
True
False
False
/api/public/snipt/29184/
select-columns
<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>Ctrl + v </span></pre></div> </td></tr></table>
vim

Bash

Turn off search highlighting

:noh
https://snipt.net/embed/50f0fc40801a2cb7bb132c12ee7a4415/
/raw/50f0fc40801a2cb7bb132c12ee7a4415/
50f0fc40801a2cb7bb132c12ee7a4415
bash
Bash
1
2019-07-03T13:06:13
True
False
False
/api/public/snipt/28663/
turn-off-search-highlighting
<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>:noh </span></pre></div> </td></tr></table>
vim

Bash

Yank a range of lines

:<start_line>,<end_line>y
https://snipt.net/embed/88f6ccc50a6f16a77d13eb298b5fc0d2/
/raw/88f6ccc50a6f16a77d13eb298b5fc0d2/
88f6ccc50a6f16a77d13eb298b5fc0d2
bash
Bash
1
2019-07-07T12:01:04
True
False
False
/api/public/snipt/26244/
yank-a-range-of-lines
<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>:&lt;start_line&gt;,&lt;end_line&gt;y </span></pre></div> </td></tr></table>
vim

Bash

Search and replace

:%s/foo/bar/gc
https://snipt.net/embed/86d5efcf47238b08e13026103ca333e4/
/raw/86d5efcf47238b08e13026103ca333e4/
86d5efcf47238b08e13026103ca333e4
bash
Bash
1
2019-07-07T17:02:59
True
False
False
/api/public/snipt/26241/
search-and-replace
<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>:%s/foo/bar/gc </span></pre></div> </td></tr></table>
vim

Bash

Navigate between words

1
2
3
4
5
# Next word
w

# Previous word
b
https://snipt.net/embed/3fd5e4a191e821b2617eaf64a1a39805/
/raw/3fd5e4a191e821b2617eaf64a1a39805/
3fd5e4a191e821b2617eaf64a1a39805
bash
Bash
5
2019-07-02T19:09:13
True
False
False
/api/public/snipt/26208/
navigate-between-words
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c1"># Next word</span> </span><span id="L-2"><a name="L-2"></a>w </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="c1"># Previous word</span> </span><span id="L-5"><a name="L-5"></a>b </span></pre></div> </td></tr></table>
vim

Bash

Go to line

:<line_number>
https://snipt.net/embed/e6d3b039d601e76d874292a3522c702b/
/raw/e6d3b039d601e76d874292a3522c702b/
e6d3b039d601e76d874292a3522c702b
bash
Bash
1
2019-06-27T17:56:47
True
False
False
/api/public/snipt/26207/
go-to-line
<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>:&lt;line_number&gt; </span></pre></div> </td></tr></table>
vim

Bash

Reload .vimrc after editing it

:so %
https://snipt.net/embed/a69cb5f004c8682599972beba6570a9e/
/raw/a69cb5f004c8682599972beba6570a9e/
a69cb5f004c8682599972beba6570a9e
bash
Bash
1
2019-07-08T17:55:36
True
False
False
/api/public/snipt/26206/
reload-vimrc-after-editing-it
<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>:so % </span></pre></div> </td></tr></table>
vim