ex, vi, view - text editors


SUBMITTED BY: Guest

DATE: June 6, 2014, 9:01 a.m.

FORMAT: Text only

SIZE: 7.6 kB

HITS: 3200

  1. NAME
  2. ex, vi, view - text editors
  3. SYNOPSIS
  4. ex [-eFRrSsv] [-c cmd] [-t tag] [-w size] [file ...]
  5. vi [-eFlRrSv] [-c cmd] [-t tag] [-w size] [file ...]
  6. view [-eFRrSv] [-c cmd] [-t tag] [-w size] [file ...]
  7. LICENSE
  8. The vi program is freely redistributable. You are welcome to copy, modify and share it with others under the conditions listed in the LICENSE file. If any company (not individual!) finds vi sufficiently useful that you would have purchased it, or if any company wishes to redistribute it, contributions to the authors would be appreciated.
  9. DESCRIPTION
  10. Vi is a screen oriented text editor. Ex is a line-oriented text editor. Ex and vi are different interfaces to the same program, and it is possible to switch back and forth during an edit session. View is the equivalent of using the -R (read-only) option of vi.
  11. This manual page is the one provided with the nex/nvi versions of the ex/vi text editors. Nex/nvi are intended as bug-for-bug compatible replacements for the original Fourth Berkeley Software Distribution (4BSD) ex and vi programs. For the rest of this manual page, nex/nvi is used only when it's necessary to distinguish it from the historic implementations of ex/vi.
  12. This manual page is intended for users already familiar with ex/vi. Anyone else should almost certainly read a good tutorial on the editor before this manual page. If you're in an unfamiliar environment, and you absolutely have to get work done immediately, read the section after the options description, entitled ``Fast Startup''. It's probably enough to get you going.
  13. The following options are available:
  14. -c
  15. Execute cmd immediately after starting the edit session. Particularly useful for initial positioning in the file, however cmd is not limited to positioning commands. This is the POSIX 1003.2 interface for the historic ``+cmd'' syntax. Nex/nvi supports both the old and new syntax.
  16. -e
  17. Start editing in ex mode, as if the command name were ex.
  18. -F
  19. Don't copy the entire file when first starting to edit. (The default is to make a copy in case someone else modifies the file during your edit session.)
  20. -l
  21. Start editing with the lisp and showmatch options set.
  22. -R
  23. Start editing in read-only mode, as if the command name was view, or the readonly option was set.
  24. -r
  25. Recover the specified files, or, if no files are specified, list the files that could be recovered. If no recoverable files by the specified name exist, the file is edited as if the -r option had not been specified.
  26. -S
  27. Run with the secure edit option set, disallowing all access to external programs.
  28. -s
  29. Enter batch mode; applicable only to ex edit sessions. Batch mode is useful when running ex scripts. Prompts, informative messages and other user oriented message are turned off, and no startup files or environmental variables are read. This is the POSIX 1003.2 interface for the historic ``-'' argument. Nex/nvi supports both the old and new syntax.
  30. -t
  31. Start editing at the specified tag. (See ctags(1)).
  32. -w
  33. Set the initial window size to the specified number of lines.
  34. -v
  35. Start editing in vi mode, as if the command name was vi or view.
  36. Command input for ex/vi is read from the standard input. In the vi interface, it is an error if standard input is not a terminal. In the ex interface, if standard input is not a terminal, ex will read commands from it regardless, however, the session will be a batch mode session, exactly as if the -s option had been specified.
  37. Ex/vi exits 0 on success, and greater than 0 if an error occurs.
  38. FAST STARTUP
  39. This section will tell you the minimum amount that you need to do simple editing tasks using vi. If you've never used any screen editor before, you're likely to have problems even with this simple introduction. In that case you should find someone that already knows vi and have them walk you through this section.
  40. Vi is a screen editor. This means that it takes up almost the entire screen, displaying part of the file on each screen line, except for the last line of the screen. The last line of the screen is used for you to give commands to vi, and for vi to give information to you.
  41. The other fact that you need to understand is that vi is a modeful editor, i.e. you are either entering text or you are executing commands, and you have to be in the right mode to do one or the other. You will be in command mode when you first start editing a file. There are commands that switch you into input mode. There is only one key that takes you out of input mode, and that is the <escape> key. (Key names are written using less-than and greater-than signs, e.g. <escape> means the ``escape'' key, usually labeled ``esc'' on your terminal's keyboard.) If you're ever confused as to which mode you're in, keep entering the <escape> key until vi beeps at you. (Generally, vi will beep at you if you try and do something that's not allowed. It will also display error messages.)
  42. To start editing a file, enter the command ``vi file_name<carriage-return>''. The command you should enter as soon as you start editing is ``:set verbose showmode<carriage-return>''. This will make the editor give you verbose error messages and display the current mode at the bottom of the screen.
  43. The commands to move around the file are:
  44. h
  45. Move the cursor left one character.
  46. j
  47. Move the cursor down one line.
  48. k
  49. Move the cursor up one line.
  50. l
  51. Move the cursor right one character.
  52. <cursor-arrows>
  53. The cursor arrow keys should work, too.
  54. /text<carriage-return>
  55. Search for the string ``text'' in the file, and move the cursor to its first character.
  56. The commands to enter new text are:
  57. a
  58. Append new text, after the cursor.
  59. i
  60. Insert new text, before the cursor.
  61. o
  62. Open a new line below the line the cursor is on, and start entering text.
  63. O
  64. Open a new line above the line the cursor is on, and start entering text.
  65. <escape>
  66. Once you've entered input mode using the one of the a, i, O or o commands, use <escape> to quit entering text and return to command mode.
  67. The commands to copy text are:
  68. yy
  69. Copy the line the cursor is on.
  70. p
  71. Append the copied line after the line the cursor is on.
  72. The commands to delete text are:
  73. dd
  74. Delete the line the cursor is on.
  75. x
  76. Delete the character the cursor is on.
  77. The commands to write the file are:
  78. :w<carriage-return>
  79. Write the file back to the file with the name that you originally used as an argument on the vi command line.
  80. :w file_name<carriage-return>
  81. Write the file back to the file with the name ``file_name''.
  82. The commands to quit editing and exit the editor are:
  83. :q<carriage-return>
  84. Quit editing and leave vi (if you've modified the file, but not saved your changes, vi will refuse to quit).
  85. :q!<carriage-return>
  86. Quit, discarding any modifications that you may have made.
  87. One final caution. Unusual characters can take up more than one column on the screen, and long lines can take up more than a single screen line. The above commands work on ``physical'' characters and lines, i.e. they affect the entire line no matter how many screen lines it takes up and the entire character no matter how many screen columns it takes up.

comments powered by Disqus