What is a shorthand?

In the vim command s/blah/meh/g, what do the s and g stand for? Are they shorthand for a longer word?

  • If not, what's a good mnemonic to remember them as?

  • Answer:

    Both "s" and "g" come from sed(1). The "s" stands for substitute and the "g" for global. The command "sed s/blah/meh/g" would replace all occurrences of "blah" with "meh" in the file, as opposed to "sed s/blah/meh/" which would just replace the first occurrence (if any) on each line. Vim's s command has inherited this flag, although it doesn't really mean global; it just means to replace all the occurrences on the current line, as opposed to simply the first one on the line. If you want truly global scope, use :%s rather than :s. (The % works with other commands too; for example :%d will cut the entire file.)

Brian Bi at Quora Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.