Skip to main content

Questions tagged [undo-redo]

Question about navigation in the undo history, undoing, and redoing changes

Filter by
Sorted by
Tagged with
1 vote
1 answer
35 views

Is there an option for setting undo files' extension, similar to the one for backups?

For backup files, there's the option backupext for changing the extension of backups from filename.ext~ to (for example) filename.ext.bak by using set backupext=.bak in a vimrc file. Is there a ...
thruse's user avatar
  • 25
0 votes
0 answers
57 views

undofile without changing :undo

I think of writing as saving, and quitting as committing. Recently I discovered "undofile" which while wonderful breaks my save/quit mental model. I'd like for ":undo" with "...
user19087's user avatar
  • 101
2 votes
1 answer
109 views

U (undo line) doesn't work on single line buffer

I am working through the user manual, doing the examples on a Mac using Vim (comes bundled with MacVim) on the terminal and was doing fine with undo (Chapter 2). Then with undo line or U, when doing ...
Miguel Cortes's user avatar
1 vote
2 answers
235 views

Restore auto-loaded file that was lost by accidently undoing edits

I accidentally removed about 1 hour of my work, how to restore? Last week I worked with file.md on my current computer and didn't save it into disk but just put my OS into a sleep mode. Yesterday I ...
Artyom's user avatar
  • 127
1 vote
0 answers
27 views

Unable to undo some symbolic links

I have the following symbolic link for my ~/.vimrc ~/.vimrc -> ~/Dropbox/Backup/Dotfiles/.vimrc When I edit this file with vim ~/.vimrc, I see an undofile is created which looks like this: %Users%...
Matt's user avatar
  • 177
1 vote
1 answer
116 views

How to merge the changes in undofile with the current version?

I use undotree to visualize the changes available in my undofile. Is it possible to merge a branch of the undofile with the current version of the file I am working on? I am looking for something ...
Matt's user avatar
  • 177
1 vote
1 answer
391 views

How to find the timestamp of changes in Vim?

I am aware of the undofiles in Vim but they are binary and I don't know how to read them. I tries strings but it didn't help for my purpose. I am also aware of the :changes command but that only gives ...
yukashima huksay's user avatar
1 vote
2 answers
407 views

How can I change undo behavior in Vim?

I'm new to Vim and install that in windows 10. I write this instructions in Vim then in normal mode pressed u and all the instructions disappeared. console.log(899) hello you can write some simple ...
mohamadi_arch's user avatar
0 votes
1 answer
41 views

How to make a keymap for a series of action atomic (which can be undo by just press one time 'u')?

Here is my keymap: nmap <A-y> viW<Plug>VSurround]%a()<ESC>h"+pF(<CR>l vmap <A-y> <Plug>VSurround]%a()<ESC>h"+pF(<CR>l Which is a markdown ...
lizhe's user avatar
  • 137
3 votes
2 answers
90 views

Undo-joining a mapping that uses the expression register

I'm trying to make semi-automatic parentheses work using vim-arpeggio and ultisnips. Everything works fine except the undo story. What I have now is this: Arpeggioinoremap () ()<c-r>=UltiSnips#...
user3240588's user avatar
1 vote
1 answer
48 views

Telling whether before or after latest save

Sometimes I get lost undo/redoing (sometimes having accidentally applied a count). I can't tell if I'm before or after the latest save and spam u/U until I see the [+] indicator next to the filename ...
geb's user avatar
  • 31
2 votes
1 answer
89 views

Disabling undodir and backupdir for specific paths

My email client creates files in /tmp and my password manager under /dev/shm when editing. The first is just unnecessary to store the undos for longer than the lifetime of the file, the latter is ...
fbence's user avatar
  • 697
2 votes
2 answers
74 views

What does this output means (in vim) when I do/undo and redo?

Whenever I do undo and redo in vim, I saw this output, the #number changes.. but what is it ? Where to see the #number .. ? Also, I find it hard to know what. I have accidentally changed or undo ...
andrew_ysk's user avatar
1 vote
1 answer
75 views

Why is my changelist not working? [closed]

I'm using homebrew-installed vim My changelist looks something like this: 10 250 0 nmap <leader>rn <Plug>(coc-rename) 9 266 11 set report=0 8 267 20 set display+=...
Aaron Parisi's user avatar
0 votes
0 answers
186 views

Can't undo past last save, but only sometimes

I am editing a *.tex file. I don't have persistent-undo set. However, I can normally undo beyond my last save so long as I don't exit the file. That's fine. Sometimes, however, I am presented with ...
user2153235's user avatar
3 votes
1 answer
376 views

How to undo in ctrl-x mode?

Let's say I just completed following path using Ctrl-x, Ctrl-f (twice) and I haven't exited the Ctrl-x mode yet and I got /home/john.doe/ Let's say I chose john.doe accidentally and actually want to ...
flawr's user avatar
  • 185
6 votes
1 answer
385 views

What does undo undo?

The undo command feels a bit random. Sometimes it undoes massive chunks, sometimes tiny changes. How is the cut-off point determined?
samuelnihoul's user avatar
1 vote
2 answers
104 views

What's the configuration used to make vim remember modifications after closing the file?

I've recently started using SpaceVim which is basically vim that comes with some extra plugins and pre-done configurations. However, it has a default behavior that bothers me... It remembers changes ...
raylight's user avatar
  • 545
3 votes
2 answers
258 views

visualize Vim undo history

Is there for Vim what Gource is for Git, to visualize Vim undo history? I'm familiar with Gundo, which display diffs of undo history, but it's not really a visualizer like Gource for Git repos.
Geremia's user avatar
  • 966
0 votes
0 answers
29 views

How can I view aggregated last undo changes in a directory with persistent undo?

I have persistent undo enabled for vim, is there someway I can inspect a directory's entire undo history? For example something like a list of files sorted by last change recorded. My intention is to ...
Chris Stryczynski's user avatar
1 vote
0 answers
29 views

How to see offscreen undo changes?

Imagine a text file with some words on the first line, one-thousand blank lines, and some text on the last line. this is a first line of text. <1000 blank lines> Last line of text. From the ...
Jordan Mandel's user avatar
1 vote
1 answer
322 views

How to save a file in Vim in a way as if :wq had been issued but without exiting the editor?

I use gh (the official GitHub CLI tool) to edit my gists from the terminal. When I issue gh gist edit <gist-ID> then Vim opens, I do the deed, and when I save the file and quit Vim (by using :...
toraritte's user avatar
  • 400
0 votes
1 answer
62 views

Why does cw followed by ctrl-r register consist of two edits?

I did cwCtrl-Ra at the beginning of a word to paste the content of register a in its place. And this, I thought, is done entering insert mode only once; or at least, never going back to normal mode. ...
Enlico's user avatar
  • 2,224
2 votes
0 answers
37 views

Method for each split to have its own undo buffer?

Often, I want to edit multiple different parts of the same file simultaneously. This is usually done with a number of splits. Is there a way such that the undo history in each split is separate? E.g., ...
Walt W's user avatar
  • 121
2 votes
1 answer
60 views

Alternative to Gundo tree that avoid messing up my window layout

There are several plugins which open a window on the left or right side, nerdtree and tagbar being just to examles. And then there's gundo, the functionality of which is invaluable, but lord... it ...
Enlico's user avatar
  • 2,224
9 votes
2 answers
657 views

Break the undo sequence in normal mode

Question: Is there something which is works same as i_CTRL-G_u, but for normal mode? This would be useful in mappings (like nnoremap), because (I think, but fixme) in normal mode, if you are just ...
Attilio's user avatar
  • 369
3 votes
1 answer
706 views

Vim undofile does not work when file is too long

I use a vim persistent undo setup as follows, which have worked all that way here. set undofile set undodir=~/.vim/undodir However now I'm facing a problem when the undofile became too long, notice ...
intmarinoreturn0's user avatar
2 votes
1 answer
314 views

Undo <count> macro instances

Often I would record a macro and run it till end of file like 200@q. However, there may be a few lines/instances at the bottom I don't want to run the macro on (like 5 lines). Pressing u would undo ...
ChocolateOverflow's user avatar
6 votes
1 answer
2k views

Why does Vim say "Already at newest change" despite a full "changes" history list?

I seem to be unable to undo something in a file I saved, despite that the history of changes shows up with I press :changes. So the change history is known to vim but I cannot access it? I thought it ...
johnbakers's user avatar
1 vote
1 answer
424 views

how do you undo a few operations in the vi editor

i have just tried something of which i don't know how it worked out but thanks it did. i have been trying to undo a few operations of dl which deleted a few letters. it didn't work as it kept on ...
galeboe ogaufi shakes gadiutlw's user avatar
7 votes
2 answers
628 views

Possible to rename file and maintain undo?

Is there a way to rename/copy/move a file and maintain the vim persistent undo information? If I do :w new-file-name and then :e new-file-name I can't hit u to undo. Already at oldest change :-(
Alec Jacobson's user avatar
2 votes
2 answers
106 views

Plugin to edit whole datasets/projects

I'm using vim all the time for text editing these days, and have a particular use case: editing a dataset using successive commands. The main problem, as often, is fixing things, ideally rather ...
Jérémie Wenger's user avatar
20 votes
1 answer
2k views

How can I undo `zg`?

I'm checking spelling in a document. I find a misspelled word and intend to press z= to get suggestions, but I accidentally press zg, marking this as a "good" spelling. How can I undo that?
Nathan Long's user avatar
2 votes
1 answer
530 views

Persistent undo erases my file

I have been trying to get persistent undo to work for over a day now. I keep having a quite unusual bug. I tried the following: " Let's save undo info! if !isdirectory($HOME."/.vim") call mkdir($...
Jim Hessin's user avatar
0 votes
1 answer
48 views

How do I receive an alert message indicating that persistent undo will be ignored?

I am using Vim 7.4. According to vim's help on persistent undo: An undo file is also ignored if its owner differs from the owner of the edited file. Set 'verbose' to get a message about that when ...
MrSnrub's user avatar
  • 431
1 vote
0 answers
36 views

partial redo/undo [duplicate]

when writing the following line a word by word: word1 word2 word3 I want to be able to undo like this: word1 word2 word word1 word2 wor word1 word2 w ... If I use u, it will remove the entire line....
Stav Alfi's user avatar
  • 121
0 votes
0 answers
46 views

How to undo all changes in current session when undofile is on? [duplicate]

Without 'undofile', one can hold u or execute undo 0. With 'undofile', everything changed, hold u will undo changes made in older sessions, undo 0 will undo the entire undo history, they became ...
dedowsdi's user avatar
  • 6,298
2 votes
0 answers
48 views

make u (undo) also reset . (repeat last command)?

Sometimes I make a change, then in my scramble to move to somewhere else that I want to repeat the change, I accidentally make some edit (e.g. ill). I would normally undo the accidental edit with u, ...
minseong's user avatar
  • 2,363
2 votes
1 answer
908 views

Reduce size of undo file

I had a very large (14 digit) decimal number in my (Windows) clipboard. I had vim open in normal mode on the command line at the time. Accidentally, I pressed some key/mouse combination that caused ...
rranjik's user avatar
  • 135
2 votes
2 answers
170 views

Automate breaking of history in insert mode

I started to learn ViM one month ago, so I'm not a ViM expert. My question is: if I make some changes in insert mode (let's say I type some text, then I delete the last two words and finally type ...
LuxGiammi's user avatar
  • 207
5 votes
2 answers
278 views

How to make insert mode mapping count as multiple undos?

I have the following mappings: nnoremap # /___<CR>ciw imap # <Esc>:w<CR><Esc># And the following file that I am editing: foo ___ goo ___ hoo ___ The idea is that I start at ...
GreenSaguaro's user avatar
1 vote
1 answer
883 views

Automatic <C-g>u to break undo block? [closed]

What possible downsides are there to using <C-g>u on a regular basis to break the undo chain in small chunks, e.g. after every line-break or after every sentence? Has someone experiences with ...
Thomas D's user avatar
0 votes
1 answer
145 views

Undo to a specific user defined point

I'm using U in normal mode to undo steps in vim, I wonder how to set a sort of a bookmark and create a undo command to undo steps/reverse to the bookmark moment in Vim. This would be nicer than just ...
SLN's user avatar
  • 547
3 votes
1 answer
598 views

Exiting and entering insert mode again with key-binding

I'd like to experiment one of the tip by Drew Neil in his Vimcast, that is to "escape" regularly, so that it gives more granularity to the "undo" command. For example, I write one short sentence. ...
Yoric's user avatar
  • 133
1 vote
2 answers
2k views

Show changes since buffer was opened

Is it possible to show all changes made to a buffer since the buffer was opened? This question https://stackoverflow.com/questions/749297/can-i-see-changes-before-i-save-my-file-in-vim is related, ...
Bananach's user avatar
  • 504
1 vote
0 answers
106 views

How can I make Vim not remember a command?

I have set up an autocommand, that makes some changes to the file I'm working on, whenever I save. Everything works nice and dandy, except one thing. Whenever I save, and press . afterwards, or undo ...
hgiesel's user avatar
  • 1,944
4 votes
1 answer
204 views

"diff"-ing current with "earlier" time

I have a file opened and I know I can do :diffsplit to open the file in a diff view. I also know that I can do something like :earlier 30m to see how the file was 30 minutes ago. My question is: how ...
ChatterOne's user avatar
3 votes
2 answers
2k views

How to drop undo history?

Previously (as far as I remember), e! used to drop undo history. Now, I'm using vim 8.0, and e! doesn't drop it. How to drop undo history in vim 8.0?
geza's user avatar
  • 133
1 vote
1 answer
764 views

How to undo the deletion of characters in insert mode caused by Ctrl-U?

I changed my Caps Lock key to Ctrl, and as I'm still getting used to it I sometimes enter combinations I didn't intend to. While in insert mode typing, having already written most of a long sentence, ...
Wildcard's user avatar
  • 4,429
1 vote
2 answers
62 views

Return to current state of file after issuing :earlier command?

Sometimes I want to get back and copy some old code that I deleted and use it. For example, I'll do: :earlier 12h and then yank the deleted code. To get back to where I was, I'll issue a command ...
StevieD's user avatar
  • 1,492