Posts Tagged ‘vi’
VI and no disk space
Tuesday, November 4th, 2008If you get the error while opening a file in vi,
“There is not enough space in the file system.
[Press return to continue]”
and you know that you have space in your home directory, than simply use this command
in vi, say
:set dir=
then press:
:e .
You will be able to see the entire file.
Suspend a VI session for shell
Tuesday, November 4th, 2008Ever want to run some shell commands while doing a vi edit session? Like, “what’s the name of that file” I want to use in this script I’m making?
Instead of exiting vi; doing the ls filenamepart*, and going back into vi, you can from a vi session:
enter “:”, then enter “shell”.
This suspends the vi session and gives you a command prompt where you can use any shell command. When finished, enter the “exit” command and you will be returned to the vi session.
How to go a particular line or word in vi
Tuesday, September 16th, 2008You can go to a particular line or word in a file using vi in several ways:
- To make vi start at a particular line in a file, add
+line_numto the command you use to start vi. Replaceline_numwith the line number, for example: vi +36 foo.c - If you’re already in vi, you can use the goto command. To do this, press
Esc, type the line number, and then pressShift-g. If you pressEscand thenShift-gwithout specifying a line number, it will take you to the last line in the file. - You can also use the ex command line to go to a line. For instance, if you wanted to go to line 14, you could press
Escand then enter: :14 - To search forward for some text, use the
/(forward slash) command. PressEscand then enter/pattern, replacingpatternwith the text for which you want to search forward. For example, to find every instance of the word “blimp”, enter: /blimp To look for the next occurrence after the first, either pressnor press/again and then pressEnter. To go back to a previous occurrence, pressShift-n. To search backwards in a file, use the?command. - To see what line you’re on at any time, press
Ctrl-Shift-g. To number all lines, pressEscand enter: :set number
Search and Replace in Vi/Vim
Wednesday, June 25th, 2008In Vi or Vim, use the forward slash </> to search. Then type in your search string and hit <Enter>. You can navigate through occurrences of your search string using <n> to move forward and <N> to move backwards.

