Tag Info

Accepted

How can I view and edit my recording (i.e. recorded macro)?

Note: I'm assuming you're using the a register for the entirety of this answer, but you can use any register Note2: <1b> is Esc; you can insert this with Ctrl+v and then Esc. It may also show ...
• 56.9k
Accepted

Execute normal command over range

You can do this with the normal command : :1,10normal d2w This is because the d operator doesn't accept a range, but only a motion : :h d ["x]d{motion} Delete text that {motion} moves ...
• 15.2k
Accepted

How to replace more than one character without entering insert mode

If the new text is the same length as the old text, Vim's replace mode is an option. From normal mode, R (that's a capital "r") brings you into replace mode. This is similar to "overwrite" in some ...
• 1,326

Delete n lines skip 1 line script

Very simple approach: Move to the first line you want to delete. Record a macro: qa3ddjq Repeat it with a high number: 1000@a Step three will repeat the macro a thousand times or until an error is ...
• 8,675
Accepted

• 504

How to copy first four characters of every line to the end of that same line?

And a solution with a macro: qqyiwA <Esc>pj0q Which means: qq Record the macro in the register q yiw Yank the text described by the text object iw (inner word): The date A <Esc> ...
• 46.5k

Replace . with -> in specific places

You could use the s operator, which deletes the character under your cursor and puts you in insert mode. You can then type the replacement and later use . to repeat the whole replacement. Workflow ...
• 7,466

Repeat motion easily

Since you mentioned cursor movement but not ; there is of course ; Repeat latest f, t, F or T [count] times. , Repeat latest f, t, F or T in opposite direction [count] times. This is very ...
• 2,673
Accepted

Repeat last yank

If you include the flag y in the cpoptions option; set cpoptions+=y then yanks may be repeated using .. See :help cpo-y: *cpo-y* y A yank command can be redone ...
• 12.8k
Accepted

How to repeat last action with movement?

From the repeat documentation : . Repeat last change, with count replaced with [count]. Also repeat a yank command, when the 'y' flag is included in 'cpoptions'. ...
• 1,490
Accepted

Understanding line reference differences through :g/^/norm and through :%norm

Well, % is shorthand for 1,\$ (a range from the first line to the last). From :he :%: Line numbers may be specified with: :range E14 {address} {number} an absolute line ...
• 23.9k

Can I repeat the last UI command?

There is no way of doing this by default in vim because vim does not keep track of the previously executed wincmd. However, it is possible to do this through some clever mappings: function! s:Wincmd(...
• 7,570

How can I add a prefix to a few lines?

What I do to achieve this is to make a visual rectangular selection with Ctrl-V at the place where I want to add the prefix, and once all lines are selected, just press I (that's a capital i) and type ...
• 2,251
Accepted

Repeat replace one character (r) for next occurence

Well, <Shift>v:s/"/'/<Enter> is certainly less efficient than :s/"/'<CR>. Here are various ways to perform the same task: f" jump to next " r' replace it with a ...
• 33.1k
Accepted

Replace . with -> in specific places

The cw(change word) command will solve your problem. Put your cursor on the period and type cw-><Escape> something.somethingelse turns into something->somethingelse and the . ...
Accepted

How can I repeat last Ex-mode command in normal mode?

Use the /c flag at the end of your substitution in order to confirm each substitution: :%s/foo/bar/gc See :help s_flags. Use & to repeat the last substitution without the flags. See :help &....
• 33.1k

repeat insert at beginning of line

Just hit the enter key. It will take you to the start of the next line.
• 1,193

How to insert repetitive text with minor difference in vim?

You can use the following function: function! GenerateLines() let firstpart="similar text part 1" let secondpart="similar text part 2" let words=["wordA","wordB","wordC","wordD","wordE"] ...
• 46.5k

Replace . with -> in specific places

I recommande using the substitute command: :%s/\./->/gc This will: :%s substitute over all lines /\. match dot /-> replace by arrow /g replace all on lines c ask for ...
• 15.2k

Replace . with -> in specific places

If you don't want to use a substitution or the dot command as suggested by the other answers your best bet is probably to create a macro which you can use when your cursor is next to a dot. You can ...
• 46.5k
Accepted

Is it possible to make a numerically-prefixed hotkey run a function that many times?

By default vim treats all functions as if they are default ex commands, i.e. any prefixed numbers are used as {range}. To change this you need to modify your function and your map to use a count. Map ...
• 2,510
Accepted

The bar | command can be used to separate multiple commands in a single command statement. Your example could be written as :1d|4d|32d http://vimdoc.sourceforge.net/htmldoc/cmdline.html#:\bar
• 226
Accepted

Is there a way to encapsulate a variable with a method with a repeatable action?

If you already have the surround plugin, you can do ysiwfverify<CR>. Tim Pope has another plugin called repeat that lets you repeat surround commands with .. Without any plugin or setup, you ...
• 33.1k