3

Is the a difference between /: and : in vi?

muru
  • 197,895
  • 55
  • 485
  • 740
JJA
  • 31

2 Answers2

6

Are you referring to vi commands?

Typing : in the vi command prompt means that you are going to write vi commands. For instance:

:x == save and exit

:w == save,

:q == quit,

:s/// == search and replace, etc.

Typing / means performing a search. So /: means that you are searching for an instance of ":" (colon) in your file.

Kevin Bowen
  • 19,615
  • 55
  • 79
  • 83
nobody
  • 4,362
0

Vi have two modes of operation:

  • Command Mode
  • Insert Mode

In command mode, the letters of the keyboard perform editing functions (like moving the cursor, deleting text, for example). To enter command mode, press the Esc key.

In insert mode, the letters you type form words and sentences. Unlike many word processors, vi starts up in command mode.

What does entering the : key mean in Vi/M editors?

The vi editor editor is built on an earlier Unix text editor called ex. ex commands can be used within vi. ex commands begin with a : (colon) and end with a . The command is displayed on the status line as you type. Some ex commands are useful when saving and closing files.

To save the edits you have made, but leave vi running and your file open:

  1. Press Esc
  2. Type :w
  3. Press Return.

/ is used for searching while in command mode

  1. Type / (slash).
  2. Enter the text string you want to search for in the file.
  3. Press Return.

So /: will search for the ":" character in subject file, while : will take user to command mode, where ex commands can be executed.

Kevin Bowen
  • 19,615
  • 55
  • 79
  • 83
GC 13
  • 291