1. Overview

Vertical separators are special characters that we use to control the layout and appearance of text on a screen or a printer.

In this tutorial, we’ll explore the difference between vertical tab, form feed, and other vertical separators in programming and text processing. We’ll understand their usage, and features, as well as compare them with each other.

2. Vertical Tab

A vertical tab is a character that moves the cursor or the print head to the next vertical tab stop. Further, a vertical tab stop is a predefined position on a page or screen where the text can start or resume after a vertical tab. Often, we use vertical tabs to create vertical spacing or alignment in text.

2.1. ASCII Representation and Encoding

Notably, we represent the vertical tab with the ASCII code 11 or the hexadecimal code 0B. In Unicode, we use U+000B to encode a vertical tab.

We can also encounter it as VT or \v in some programming languages, such as C, Java, and Python.

2.2. Usage in Programming and Text Processing

Vertical tabs are rarely used in modern programming as they aren’t directly supported by most applications and devices. However, they can still be found in some systems or formats:

In these systems, we can use vertical tabs to create tables, charts, or other structured layouts.

Let’s look at an example of how we can use vertical tabs in Python:

$ cat hello.py
my_string = "Hello\vWorld"

Now, we can run the Python code using the python3 command:

$ python3 hello.py

Thus, we can see what the vertical tab looks like.

3. Form Feed

In contrast, a form feed is a character that moves the cursor or the print head to the top of the next page or form. Also, we often use a form feed to indicate the end of a logical page or a section in a document.

3.1. ASCII Representation and Encoding

A form feed is represented by the ASCII code 12 or the hexadecimal code 0C. In Unicode, we encode a form feed as U+000C.

Separately, we can encounter it as FF or \f.

3.2. Features and Usage

One of the primary features of the form feed character is to indicate a page break. In many printing systems, especially in the context of line printers, a form feed character signals the start of a new page

Further, in text processing, we use the character to separate sections or chapters of a document. When encountered, it signifies the beginning of a new logical unit.

However, in programming languages and regular expressions, we often use \f as an escape sequence representing the form feed character.

We can look at an example in Python programming:

$ cat form_feed.py
print("This is line 1.\fThis is line 2.")
$ python3 form_feed.py
This is line 1.
               This is line 2.

In this Python example, the \f character causes the cursor to move to the next page, which, in this case, the program represents by additional leading spaces on the second line.

4. Other Vertical Separators

Besides vertical tab and form feed, there are other vertical separators that we use in text processing. Let’s briefly see some of them.

4.1. New Line Character

A new line character moves the cursor or the print head to the beginning of the next line. In addition, the new line character has the code 10 in ASCII representation and U+000A in Unicode. In programming, we can often represent it with the escape sequence \n.

Further, in some systems, especially older ones, we can represent the new line character as a combination of Carriage Return (\r) and Line Feed (\n). This is known as CRLF and we commonly use it in text files on Windows systems.

4.2. Carriage Return Character

The primary function of the carriage return character is to move the cursor or print head to the beginning of the current line. Therefore, it enables subsequent text to overwrite or replace the existing content on that line.

In ASCII, the carriage return character has the code 13. In Unicode, we represent it using the code point U+000D. We can also represent it in programming with the escape sequence \r.

Further, one use of this character is in formatting text, especially in situations where we want to overwrite or position the cursor at the beginning of a line.

For instance, we can use \r to update progress on the same line in command-line interfaces. Let’s look at a Python code to demonstrate this:

$ cat update_progress.py 
import time

for i in range(11):
    print(f"Progress: {i}/10", end='\r')

print("\nTask complete!")

This code outputs a progress bar updating on the same line.

4.3. Line Separator and Paragraph Separator

We can represent the line separator character by the Unicode code point U+2028. Literally, we use the character to separate lines in a way that is more neutral when we compare it to the typical newline character.

Similarly, we can represent the paragraph separator character by the Unicode code point U+2029. Also, it separates paragraphs and provides a way to break paragraphs without implying a new paragraph.

While these characters are similar to the new line character, they’re designed to separate lines or paragraphs in a more neutral, semantic, and explicit way. They also often ensure a more consistent behavior across platforms.

For instance, we use them in JavaScript and markup languages to represent line or paragraph breaks within string literals.

5. Conclusion

In this article, we’ve learned what vertical tabs, form feeds, newline characters, and other vertical separators in programming and text processing are. Further, we understood their usage, features, and encoding details, as well as compared them with each other.

Notify of
Inline Feedbacks
View all comments