Questions tagged [repeated-commands]

Questions about replaying the same command. This includes the dot command (.), @ macros,  @:  and similar methods.

Filter by
Sorted by
Tagged with
0
votes
0answers
30 views

Is there a modification to make the dot command work intuitively in visual mode?

This is a repeat of a question that I asked on the Vim subreddit but didn't receive a helpful answer for. I think that this should be do-able, but I'm not good enough at Vimscript or Lua yet to ...
0
votes
1answer
34 views

Is it possible to properly repeat a visual replacement?

It is possible in vanilla vim to: visual select some number of characters, e.g. a variable name in code type c to begin replacing selection in insert mode type a replacement (variable name) exit ...
1
vote
1answer
17 views

How to make dot replay embedded normal command? e.g in insert mode: <c-o>ysiw>Some<esc>

For example: OpRef ^- cursor I press <c-o>ysiw>Option<esc> in insert mode to get: Option<OpRef> I want to repeat this command with dot operator, but when I press dot it only ...
2
votes
2answers
244 views

Repeat complex actions over a number of lines (in Vim)

I am editing a LaTeX document and I wanted to figure out the most efficient way to convert itemize environment to tabular environment. Here is an example of what I want to accomplish: Change \begin{...
4
votes
1answer
62 views

Register for your last action (.)

Vim has a lot of useful registers from which you can access the contents of various actions. There's ": for the last command in the command line, "/ for the last search, ". for the last ...
2
votes
0answers
40 views

Vim: is there a way to persist the last edit?

When you make a change, like ifooESC to insert the text foo, this can, of course, be repeated using .. However, if you quit Vim, in spite of Vim saving all sorts of state, including the contents of ...
1
vote
0answers
35 views

How to do a motion without leaving history (in .)?

Often, you do a complicated motion, which you want to repeat soon by pressing . but carry out a simpler motion overwrites that one. Can I keep that complicated motion in . itself ? Concrete example: ...
0
votes
1answer
33 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. ...
1
vote
3answers
847 views

Repeat a command line multiple times

I want to turn one two three four into 'one' 'two' 'three' 'four' (I have surround.vim) I can do: ysiW', then do W. repeatedly until I've surrounded all words in the line But I would like to repeat ...
3
votes
3answers
1k views

Execute command for multiple files

I find myself often in the situation in which I want to run multiple vim commands on a multiple files. Consider file1.txt, file2.txt, file3.txt I would need to run :retab and then some :%s/ /, / for ...
-2
votes
1answer
47 views

Vim: Append to each line in a "[I" query

I have a large config file, where many different instances of a particular config format appear. I would like to take every line where a particular word appears and add some text after it. ...
1
vote
0answers
27 views

How can I repeat a custom function mapped using `vnoremap` using something similar to the dot (`.`) operator?

I have this custom function in my ~/.vimrc mapped to Visual mode using vnoremap. After having executed the function using <leader><space>, how execute it again using something similar to ...
0
votes
3answers
323 views

Conditional search and replace using repeated macro or commands

I want to search for a keyword, and replace a word in the line that is not a search word. I thought macros may be a good way to do it, but I am open to any methods. I have something like, blah blah ...
1
vote
3answers
100 views

How to use macros or any other way to add @Column and turn the below code into snake_case from camelCase?

Say that I have a java class with these fields(included only few fields, but the idea is that there could many more fields). public class Entity { private String firstName; private String ...
1
vote
1answer
75 views

Repeating a combination of commands mapped to a single key

I have a mapping to "Stamp" text over the current word that cursor is on: nnoremap S "_diwP. When I do S and then try to repeat it with dot . only the last command will be repeated: P. Is it possible ...
0
votes
1answer
130 views

How to repeat short sequences of characters

I want to replace a sequence of 6 hex digits (hex RGB) with new values, but I want to repeat a 2-tuple 3 times. For example: Start: #ea9081 (with the cursor on 'e') Desired: #f0f0f0 I know I can ...
2
votes
2answers
94 views

How to replay ex commands in order?

I often have a situation where I will direct some output to a file then open it in vim and use ex commands (substitution, keep lines, delete lines, etc) to massage the output to a form I want. However ...
2
votes
1answer
63 views

Is it possible to prevent a mapping from being repeated with a prefix number (vim range)?

Sometimes it is possible to accidentally hit some numeric keys. I have a lot of binds and for most of them there is nothing to be gained by allowing them to repeat with a prefix. Let's suppose that ...
1
vote
0answers
29 views

Save & recall favourite vim :commands

I often find myself using the up arrow at the vim command prompt : Is there a way to 'favourite' some? Or at least an easy way to search through previous commands? For example, I couldn't remember ...
1
vote
2answers
110 views

Preventing an autocmd from overriding last cmd - :<bang><bang> (:!!)

I have an autocmd set up like this: au BufWritePost *.sh,*.zsh,.zshrc silent exec "!ctags --language-force=sh %" When I run :!!<cr> after saving a file, the command !ctags --language-force=sh %...
2
votes
1answer
69 views

Repeat last "change inside text object" command without the inserted text

Is there some way to repeat something like cit and be left in insert mode instead of automatically repeating the previously entered text? For example, suppose I have the following lines: <th>...
6
votes
2answers
129 views

Should the output of the -w {scriptout} flag work to replay actions using the -s {scriptin} flag?

According to the :help startup-options, this is -w's behviour -w {scriptout} All the characters that you type are recorded in the file "scriptout", until you exit Vim. This is ...
1
vote
1answer
283 views

Replay a vim macro until specified line number

Suppose caret is on the line 10 and I've recorded macros @d. I need to replay macros until line 25. If I know that macros move caret one line per execution, I can calculate that it should be executed ...
1
vote
0answers
70 views

Repeat <Leader> mapping without having to press/release full combination

Similar to this question, I want to be able to resize my splits in a repeatable manner, but without having to use a plugin. I currently use the mapping: nnoremap <Leader>q <C-w>10< ...
0
votes
0answers
66 views

Find out last used text object

I'm trying to figure out a way to make a repeatable operator insert. To do so I'm trying to make use of tpope/repeat. My idea is to set a repeatable call that repeats the last operation, repeating the ...
0
votes
2answers
139 views

Making operator insert and append repeatable

Is there an insert and append operation that can be followed by a text-object? I've found this plugins: https://github.com/deris/vim-operator-insert https://github.com/mwgkgk/vim-operator-insert ...
2
votes
0answers
181 views

What happens when error occurs during cdo?

:h :cdo says: When an error is detected execution stops. The last buffer (or where an error occurred) becomes the current buffer. Let's see what really happens: ...
2
votes
3answers
845 views

How to apply a macro for every single matching pattern

Macros can be repeated for every line matching a pattern with the global command as explained in this answer. This applies to every single line, but is it possible to do it for every single match? so ...
10
votes
6answers
2k views

Delete n lines skip 1 line script

I want to create a basic Vim script that simply deletes n lines, skips 1 line and repeats until the end of the document. I don't care about specific matches, I just want to delete the line. For ...
5
votes
5answers
1k views

How to apply a register to a command?

I have the given file 4 apples 2 bananas 6 peaches 3 grapes 1 pineapple 5 pears 3 tomatoes What I want to do is to recieve the following result instead: apple apple apple apple banana banana peach ...
2
votes
0answers
43 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, ...
2
votes
1answer
431 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 ...
1
vote
1answer
519 views

Repeat last normal command

Well, there is ; to repeat the last move in some cases. There is the . to repeat last change. But if I just did za or @a, is there a way to repeat it? I guess such a mechanism should ignore plain ...
1
vote
2answers
54 views

Valid usecases for `=` macro register

I happen to come across the = register. I checked :h @= and :h recording where it is mentioned. I am not able to understand how to use it. It could be helpful to know a valid usecase for the same.
0
votes
1answer
38 views

Running previous run command that was run in normal mode using colon

Recently I had to compile a latex file a few times, :!pdflatex filename.tex did the trick. But is there a way in normal mode to repeat commands like these which are in the recent history,but used ...
0
votes
2answers
59 views

prepend word before every function argument

accidentally just wrote void foo(bar, baz, que) { and forgot to specify type, I want to convert the above to void foo(String bar, String baz, String que) { How can I do that quickly?
1
vote
0answers
112 views

Repeat Emmet commands in vim with dot operator

Is there a way i can repeat an emmet command in vim. Below is the sample text file <h1>Hello World</h1> <h1>Hello World</h1> So i use emmet to wrap the the first line inside ...
1
vote
0answers
54 views

Repeat previous square bracket command [duplicate]

I am using the ] commands (e.g. ]]) a lot and have a bunch of custom ones too. Is there a command that repeats the last such command, similar to how . repeats the last edit?
7
votes
1answer
1k views

Repeat last yank

I'm appending text to "a" register with:"AyW. If I wanted to repeat last change I would use:. But in this case I would like to repeat the last yank command. Is there a command to repeat the last yank (...
2
votes
2answers
276 views

Repeat complicated motions

I know that similar things were asked here several times. I know that to repeat a motion ; works. Unless it doesn't(in case there is count for example), but then repmo.vim usually works. And I know ...
4
votes
1answer
394 views

How do I run a shell command periodically and silently from within Vi?

Before I came here, I went to executing command from within Vim and learned it can be done using: :!command Then I went to executing it silently and figured how that I need to run: :silent exec ...
0
votes
2answers
64 views

how to replace N characters without having to press <esc>, is it possible?

In command mode, r replaces the character under the cursor by the one pressed right after typing r without going into insert mode, so there's no esc to press. 5r replaces the 5 characters starting ...
11
votes
2answers
924 views

Save last action (.) in a macro

Use Case I'm in normal mode. I've not explicitly thought about recording a macro, but I make a single command change. I can now repeat this action by using dot. I now realize it's a useful action to ...
0
votes
1answer
1k views

How to format csv with regex

I have a csv that looks like this: 1,wer123,name,address1,age,2,cde789,name,address1,address2,age,3,529owq,name,address1,age and so on. I want this csv to be formatted as 1, wer123, name, ...
3
votes
1answer
93 views

Repeat not only last command

The repeat command . is awesome. Is it possible to cycle through the last few commands, instead of only being able to repeat the last command? Something like yankring for repeat?
1
vote
0answers
86 views

Macros behaving unexpectedly (not executing commands)

I have the following macro let @f='ivoid function (void param^[o {^M^M^[3kwi' where ^[ represents ESC and ^M new line. for some reason it does not execute anything after the 3k, I tried replacing ...
1
vote
1answer
112 views

Quickly creating JSON entries in an Avro schema

Is there a quicker way to create more entries of form { "name": FIELD_NAME, "type": "string" } from a list of words down below, than recording a macro to process each word and then pasting the result ...
1
vote
1answer
120 views

Vim - edit last action before using (.)

Related to but not duplicate¹ of Bundling command sequences together for repeat (.). The point (.) command is really useful to redo the last action (insertion, replacement, etc.). Sometimes I find ...
0
votes
1answer
144 views

how to accept count for visual block ctrl+a remap?

I have created a vmap but I can't figure out how to apply a count to it. In this case, the mapping is on <C-a> and 4<C-a> is an example of a command with a count failing to be applied. We ...
1
vote
0answers
277 views

How to repeat last mapping/action?

I know that I can repeat last change with ., last command with @: and last motion with repmo plugin. What about other actions such as switching to the previous/next tab (gT/gt)? Is there a command for ...