04. How to replacing text in Vim r, R, ~ (tilde), c, C

We can use text replacements to edit more efficienctly. To replace a character, we simply place our cursor under the character we wish to replace, press "r", then the new character. r - replace a selected character with another ra replaces selected character with "a" 3ra replaces three characters with "a" Try replacing the incorrectly spelled character in this sentance. Now try replacing four characters in this sentence. We can also use substitution: s - replace a char and add more S - change the entire line If you want to change the case of a letter, simply press the squiggly ~ (tilde). This is located on the top left corner of your keyboard, below the ESC key. ~ - change the character case 3~ changes 3 character's case every line should start with a capital letter. FBI Now remember I told you that vim is a modal editor? There's another nift mode called REPLACE. With it, you can write over existing text. R - activate Replace mode Press "R" and you replace as you go! For a quick change, you can use the "c" key c - delete and insert cw - delete selected word and insert a new on cc - change entire line, same as "S" C - change line from where your cursor is Try changing this line $ from the "$" symbol! Review Questions: 1) Insert some random text into this sentence, then undo with one command. 2) Redo what you just undid in question 1. Solutions: 1) "U" 2) ctrl+r

Take your Linux skills to the next level!

The Linux Command Line

Take your Linux skills to the next level! Try Linux & UNIX

The Linux Command Line takes you from your very first terminal keystrokes to writing full programs in Bash, the most popular Linux shell. Along the way you'll learn the timeless skills handed down by generations of gray-bearded, mouse-shunning gurus: file navigation, environment configuration, command chaining, pattern matching with regular expressions, and more.

$ Check price
39.9539.95Amazon 4.5 logo(274+ reviews)

More Linux & UNIX resources

Aching back from coding all day?

Acupressure Mat & Pillow

Aching back from coding all day? Try Back Problems

Relieve your stress, back, neck and sciatic pain through 1,782 acupuncture points for immediate neck pain relief. Made for lower, upper and mid chronic back pain treatment, and improves circulation, sleep, digestion and quality of life.

$$ Check price
144.87144.87Amazon 4.5 logo(1,890+ reviews)

More Back Problems resources