Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong><code>2&gt;&gt;</code></strong></p> <p>The behavior you describe is due to how <code>{count}</code> works with <em>line-wise commands</em>: it doesn't perform the command <code>{count}</code> times but considers <code>{count}</code> as the number of lines on which to act.</p> <p>You can get a glimpse at how Vim does its thing by doing <code>2:</code>, this is what you should get in the command-line:</p> <pre><code>:.,.+1 </code></pre> <p>Doing <code>2&gt;&gt;</code> is thus the equivalent of:</p> <pre><code>:.,.+1&gt; </code></pre> <p>"Indent this line and the one below by one level".</p> <p>In normal mode, just hit <code>&gt;&gt;</code> to indent the current line by one level and repeat until you are at the right level.</p> <p>If you want <code>2&gt;</code> to indent by two levels, you must first visually select the line: <code>V2&gt;</code> or <code>v2&gt;</code>.</p> <p>If you want to "fix" the indentation of the current line so that it matches the indentation of the surrounding lines (the most common scenario for such a task), hit <code>==</code>.</p> <p><strong><code>10G</code></strong></p> <p><code>G</code> expects a <code>{count}</code> to jump to the corresponding line. Without a <code>{count}</code> it defaults to jumping to the last line: you can see it as a convenient shortcut for <code>{lines in buffer}G</code>.</p> <p>So you are inverting things a little: <code>G</code> is not "jump to last line", it's "jump to line <code>{count}</code> but without a <code>{count}</code> so let's go the last one".</p> <p><em>-- Startedit --</em></p> <p>Let's reverse-engineer <code>G</code> for fun:</p> <ol> <li><p><code>G</code> is first conceived as the normal mode equivalent of <code>:number&lt;CR&gt;</code>.</p></li> <li><p>It is decided that, instead of doing <code>G23</code>, the <code>{count}</code> mechanism is used so we have <code>23G</code>. <code>G</code> is not an operator: it doesn't wait for a target.</p></li> <li><p>But what do we do with <code>G</code>, without a <code>{count}</code>?</p></li> <li><p>Generally, a buffer has two "special" lines: the first and the last. Maybe we can decide what the default destination for <code>G</code> is? Why not? We hate wasted keys!</p></li> <li><p><code>G</code> is not much shorter than <code>1G</code> but it's shorter so that could be a good idea to make <code>G</code> jump to the first line.</p></li> <li><p>But what about the last line? <code>12G</code> is OK when we <em>know</em> there are 12 lines in the buffer but what about 1257 lines? What about an unknown number of lines? Is it that efficient to look up the number and type <code>2431G</code>? No, at that point, we might as well do <code>:$&lt;CR&gt;</code>. Well, why don't we use <code>G</code>, here? It is vastly shorter and quicker than any other way to reach the last line.</p></li> </ol> <p>(this is pure speculation, of course, I have no idea what Bill Joy had in mind when he designed <code>G</code>.)</p> <p><em>-- Endedit --</em></p> <p><strong>Fixing Vim</strong></p> <p>Generally, Vim doesn't need to be "fixed". Instead, you must learn how it works and how to leverage its power. Most of it makes a lot of sense: when you'll "get it" the reward will be huge.</p> <p>Also, the behavior of <em>everything</em> is explained in <code>:help</code>: learning how to use it is the number one skill you must grow if you are serious about using Vim.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload