How do I replace all characters in a visual block with one character?
Answer
<C-v>selection r{char}
Explanation
In visual block mode, pressing r followed by a character replaces every character in the selected rectangle with that character.
How it works
- Select a block with
<C-v>and motions - Press
rfollowed by the replacement character - Every character in the block is replaced
Example
aaa bbb
aaa bbb
aaa bbb
Select the bbb column and press rx:
aaa xxx
aaa xxx
aaa xxx
Tips
- This is a quick way to create visual separators or masks
- Works with any character including spaces
r<CR>replaces with newlines (breaks each line)- Combine with
$to replace to end of each line