Learning the vi Editor

Learning the vi EditorSearch this book
Previous: 2.4 More Ways to Insert Text Chapter 2
Simple Editing
Next: 2.6 Review of Basic vi Commands
 

2.5 Joining Two Lines with J

[J] Sometimes while editing a file you will end up with a series of short lines that are difficult to scan. When you want to merge two lines into one, position the cursor anywhere on the first line, and press J to join the two lines.

Suppose your file practice reads:
With a
screen editor
you can
scroll the page, move the cursor
KeystrokesResults
J
With a screen editor
you can
scroll the page, move the cursor

J joins the line the cursor is on with the line below.

.
With a screen editor you can
scroll the page, move the cursor

Repeat the last command (J) with the . to join the next line with the current line.

Using a numeric argument with J joins that number of consecutive lines. In the example above, you could have joined three lines by using the command 3J.

2.5.1 Problem Checklist


Previous: 2.4 More Ways to Insert Text Learning the vi EditorNext: 2.6 Review of Basic vi Commands
2.4 More Ways to Insert Text Book Index2.6 Review of Basic vi Commands

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System