02. How to use Vim to insert, open and join lines o, O, J

Let's say you want to append some code beneath a line. To do this, we had to go to our line, then press "A" and ENTER. Remember that even two key strokes is sometimes too much in Vim. Thankfully, Vim makes this process much easier with the "o" key. Think of "o" as in open. To add a line, use: o - open a line below O - open a line above Let's add some comments to this python function: def sumAndSquare(a, b): #comment here sum = a+b # another comment here return sum ** 2 We can also join lines together. J - join current line with the one below Turn this block of text back into one line! Review Questions: 1) Insert a period at the end of this line 2) Insert a "please" in front of the following sentences: give me a cookie. don't text and drive. Solutions: 1) A. 2) on each line, type "IPlease"

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

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

Ad