home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  

UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 30.37 Neatening Lines Chapter 30
vi Tips and Tricks
Next: 31. Creating Custom Commands in vi

30.38 Finding Your Place with Undo

Often, you're editing one part of a file, and need to go to another point to look at something. How do you get back?

You can mark your place with the m command. In command mode, type m followed by any letter. (We'll use x in the example.) Here are the commands to do the job:

m x

Marks current position with x (x can be any letter).

' x

Moves cursor to first character of line marked by x .

` x

Moves cursor to character marked by x .


Returns to exact position of previous mark or context after a move.


Returns to the beginning of the line of the previous mark or context.

But I often find it just as easy to simply type u to undo my last edit. That pops me right back to the place where I was editing. Then I type u again to restore the edit. (I still use m if I want to mark more than one place.)


Previous: 30.37 Neatening Lines UNIX Power Tools Next: 31. Creating Custom Commands in vi
30.37 Neatening Lines Book Index 31. Creating Custom Commands in vi

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System