How to return (ctrl + z) to vi / vim

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

+43
undo vim vi undo-redo back
Sep 15
source share
5 answers

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

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

+86
Sep 15 '12 at 9:27
source share

The answer u , (and many others) is in $ vimtutor .

+2
Sep 15 '12 at 9:35
source share

On mac, you can also use the Z command and this will be undone. I'm not sure why, but sometimes it stops, and if yours, like me and vimtutor, is at the bottom of this long list of things you need to learn, you can just close the window and open it again and work fine.

0
Mar 04 '14 at 6:14
source share

Here is the trick. You can map the keys Ctrl + Z. This can be done by editing the .vimrc file. Add the following lines to the .vimrc file.

 nnoremap <cz> :u<CR> " Avoid using this** inoremap <cz> <co>:u<CR> 

This may not be the preferred method, but may be used.

** Ctrl + Z is used on Linux to pause the current program / process.

0
Oct 20 '16 at 4:41
source share

I had the same problem right now and I solved it. You no longer need this, so I write for others:

if you use gvim in windows you just add this to your _vimrc : $VIMRUNTIME/mswin.vim behave mswin

else just use imap ...

0
Feb 08 '17 at 16:07 on
source share



All Articles