The file reverts to the most recently changed version. So, if you
just did a :w, you are stuck with the changes up to that point. If you just want to undo a few bad
edits, type u to back out of your changes.
You have learned a few vi editing commands. I describe more commands in the following sections.
First, however, here are a few tips to smooth out your first trials with vi:
Esc??”Remember that Esc gets you back to command mode. (I??™ve watched people press
every key on the keyboard trying to get out of a file.) Esc followed by ZZ gets you out of
command mode, saves the file, and exits.
u??”Type u to undo the previous change you made. Continue to type u to undo the
change before that, and the one before that.
Ctrl+R??”If you decide you didn??™t want to undo the previous command, use Ctrl+R for
Redo. Essentially, this command undoes your undo.
Caps Lock??”Beware of hitting Caps Lock by mistake. Everything you type in vi has a
different meaning when the letters are capitalized. You don??™t get a warning that you are
typing capitals??”things just start acting weird.
:! command??”You can run a command while you are in vi using :! followed by a command
name. For example, type :!date to see the current date and time, type :!pwd to see
what your current directory is, or type :!jobs to see if you have any jobs running in the
background.
Pages:
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240