Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

11
  • 2
    Can change norm! G for a single $ Commented Oct 1, 2019 at 17:59
  • @Matt It depends on what you want to do, as :h norm says this commands allows you to write as an ex command a normal mode command. Which means that norm G is the equivalent of pressing G while you are in normal mode i.e. going to the last line of the file. If you use norm $ you will put your cursor at the end of the first line. Commented Oct 1, 2019 at 18:03
  • 2
    I mean only $ without norm. That's an Ex command itself. Commented Oct 1, 2019 at 18:35
  • 2
    @filbranden If the command contains a single quote, you may be tempted to surround it with double quotes instead of single quotes. In a double-quoted string, bash and zsh may interpret the dollar sign as a reference to an environment variable name (this can happen for example if you try to run a global command whose last line specifier is $). Commented Oct 1, 2019 at 20:56
  • 2
    @filbranden If you run a command consisting of only a line specifier, and if it's followed by another command separated by a bar, Vim seems to interpret the line specifier command as :p, so in addition to moving the cursor on the line, it also has the undesired effect of printing it (compare :$ vs :$|let var=0; both move the cursor, but the second one also prints the last line). To avoid this pitfall, you can use :exe (e.g. :exe '$'|let var=0). Commented Oct 1, 2019 at 20:56