Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to go back (ctrl+z) in vi/vim

In normal text editors [with all due respect to Vim] there is a shortcut Ctrl+Z when you have done something nasty and want to return to the previous version of the text. Like BACK button in Word. I wonder how can you achieve this behaviour in Vim.

like image 572
Slazer Avatar asked Sep 15 '12 09:09

Slazer


People also ask

How do I undo an undo in vi?

Undo Changes in Vim / Vi To undo changes in Vim and Vi use the u , :u or :undo commands: If you are in insert or any other mode, press the Esc key to go back to the normal mode, which is also known as command mode. Type u to undo the last change.

How do I go back in vi search?

To find a character string, type / followed by the string you want to search for, and then press Return. vi positions the cursor at the next occurrence of the string. For example, to find the string “meta,” type /meta followed by Return. Type n to go to the next occurrence of the string.

How do you go back a word in Vim?

Use b to go back a word.


1 Answers

You can use the u button to undo the last modification. (And Ctrl+R to redo it).

Read more about it at: http://vim.wikia.com/wiki/Undo_and_Redo

like image 71
Qiau Avatar answered Sep 19 '22 02:09

Qiau