Skip to main content
Share Your Experience: Take the 2024 Developer Survey
5 votes
Accepted

How do I play a macro, but *slowly* (for debugging a macro)

You may be able to set the 'writedelay' option. This will delay refreshing the screen by the given number of milliseconds. So try :set writedelay=50 and run your macro. Note, that if you use ...
Christian Brabandt's user avatar
4 votes

How do I play a macro, but *slowly* (for debugging a macro)

What you could do to achieve something like this is to convert your macro into another one that introduce 1 second delay between the operation using the 1gs operation or if in insert mode ^o1gs e.g.: ...
Vivian De Smedt's user avatar
3 votes
Accepted

Update the display when :normal is busy

Turns out, this was an XY problem the whole time. The reason I wanted to do this was that calling a macro recursively would kill the whole macro chain when it hits the base condition, i.e. if your ...
typecasto's user avatar
3 votes

Delay inside Macro - Is It Possible in Vim Macros to Create a Delay Between Commands?

You can use the gs command to introduce a delay. This command can be prefixed with a count to specify the number of seconds. Refer to the help page for more information. For example, to introduce a ...
Yegappan Lakshmanan's user avatar
3 votes
Accepted

Vim macro to copy paste text

I would do (assuming you run the macro from Normal mode): 0lyg_+f[p Or: ^[0lyg_+f[p If you plan to run the macro from insert mode. Where ^[ stand for Esc 0 go to the start of the line l move one ...
Vivian De Smedt's user avatar
2 votes

How to map q for saving and quitting?

(cross-posted from SO) First things first: Vim is Vim, not Vi. They have lots of things in common but even more differences. If you absolutely want to learn from a book, pick a book about Vim, not a ...
romainl's user avatar
  • 41.1k
2 votes

How to map q for saving and quitting?

The answer of @MaximKim is the modern one. When Joy and Horton say at paragraph 6.9: :map q :wq^V^VCR CR They actually mean: :map q :wqCtrl vCtrl vEnterEnter The document you are reading is about vi ...
Vivian De Smedt's user avatar
2 votes
Accepted

How to map q for saving and quitting?

Only for normal mode: nnoremap q :<C-u>wq<CR> or nnoremap q <cmd>wq<CR> PS, be aware with mapped q you will have trouble to work with macro recordings.
Maxim Kim's user avatar
  • 13.5k
1 vote

How can I write a vanilla function or macro to align characters generally?

This is a very popular request and since there are no obvious perfect solution there are a number of plugins that address it. Here are some of the popular choices: vim-easy-align tabular vim-lion
Vivian De Smedt's user avatar
1 vote

Macros on lines with different structures

I would have the following macro: /\v(,|.})^Ma^M^[ And I would call it repeatedly. Where: ^M stands for Enter and ^[ stands for Esc
Vivian De Smedt's user avatar
1 vote
Accepted

Delay inside Macro - Is It Possible in Vim Macros to Create a Delay Between Commands?

To address your requirement of being able to read the output, I'd move the delay into the shell command: :let @p = "0D:!ping -c1 8.8.8.8 ; sleep 1\<CR>iJust pinged a DNS Server\<Esc>&...
Rich's user avatar
  • 32.1k
1 vote

Put the highest count into a register and run macro that number of times, plus a contigency

You can use variable's value in a command via execute: execute 'norm!' @z + 50 .. @l However, given your file format and existing code, there's a simpler method. You can make register l into a ...
Rich's user avatar
  • 32.1k
1 vote
Accepted

Repeat many times without macro?

I think you are confusing "macro" and "recording", here. The result of a recording is indeed a macro, but the RHS of a mapping and the argument of :normal are also macros. :normal ...
romainl's user avatar
  • 41.1k

Only top scored, non community-wiki answers of a minimum length are eligible