LinuxCommandLibrary

view

TLDR

Open a file in read-only mode

$ view [file]
copy
Open multiple files in read-only mode
$ view [file1] [file2]
copy
Open at a specific line number
$ view +[line_number] [file]
copy
Open and jump to pattern
$ view +/[pattern] [file]
copy

SYNOPSIS

view [options] [file ...]

DESCRIPTION

view is a read-only mode of Vim. It is equivalent to running vim -R and opens files with the readonly option set, preventing accidental modifications.
You can still navigate, search, and use all viewing features of vim. Attempting to save will produce a warning, though you can force a write with :w! if you have permission.
All standard vim commands work for navigation: h/j/k/l for movement, / for search, G to go to end, gg to go to start, :q to quit.

PARAMETERS

All vim options are available. Common ones include:
+num

Open file at line number.
+/pattern
Open file at first occurrence of pattern.
-c command
Execute command after loading file.
-n
No swap file (useful for sensitive files).
-o
Open files in horizontal splits.
-O
Open files in vertical splits.
-p
Open files in tabs.

CAVEATS

While view prevents accidental saves, it doesn't prevent editing the buffer entirely. For stricter read-only mode, use vim -M which disables all modifications. Unlike less or cat, view loads the entire file and uses swap files by default.

HISTORY

view has been part of vi and vim since the early days. The original vi was written by Bill Joy at UC Berkeley in 1976. vim (Vi IMproved), created by Bram Moolenaar, was first released in 1991 and included view as a standard way to invoke read-only mode. The naming follows Unix convention where different names for the same binary trigger different behaviors.

SEE ALSO

vim(1), less(1), cat(1), more(1)

> TERMINAL_GEAR

Curated for the Linux community

New Raspberry Pi 3 Model B+ Board Raspberry PI 3B+

New Raspberry Pi 3 Model B+ Board Raspberry PI 3B+

$54.00
BOSGAME Mini PC N95, Intel 12th Mini Computers| 16GB DDR4 RAM| 512GB M.2 2280 SSD| 4K 60HZ Triple Displays by Dual HDMI+Type-C, 6W TDP Quiet Mini PC, WIFI5, BT 5.0 Office

BOSGAME Mini PC N95, Intel 12th Mini Computers| 16GB DDR4 RAM| 512GB M.2 2280 SSD| 4K 60HZ Triple Displays by Dual HDMI+Type-C, 6W TDP Quiet Mini PC, WIFI5, BT 5.0 Office

$239.99
Bmax Mini PC B2 Power Intel 5205U 8GB DDR4 256GB M.2 NVMe SSD ,HDMI 1.4&DP 1.2, USB3.2,4K Dual Display 2.4G/5G WiFi & BT5.0 Mini Desktop Computers /Office/Design

Bmax Mini PC B2 Power Intel 5205U 8GB DDR4 256GB M.2 NVMe SSD ,HDMI 1.4&DP 1.2, USB3.2,4K Dual Display 2.4G/5G WiFi & BT5.0 Mini Desktop Computers /Office/Design

$169.99
Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community

BOSGAME Mini PC N95, Intel 12th Mini Computers| 16GB DDR4 RAM| 512GB M.2 2280 SSD| 4K 60HZ Triple Displays by Dual HDMI+Type-C, 6W TDP Quiet Mini PC, WIFI5, BT 5.0 Office

BOSGAME Mini PC N95, Intel 12th Mini Computers| 16GB DDR4 RAM| 512GB M.2 2280 SSD| 4K 60HZ Triple Displays by Dual HDMI+Type-C, 6W TDP Quiet Mini PC, WIFI5, BT 5.0 Office

$239.99
New Raspberry Pi 3 Model B+ Board Raspberry PI 3B+

New Raspberry Pi 3 Model B+ Board Raspberry PI 3B+

$54.00
Lenovo Gen 13 ThinkPad X1 Carbon Touchscreen Laptop with Intel Ultra 7 265U Processor, 14" WUXGA 100% sRGB, 32GB DDR5 RAM, 1TB NVMe Performance SSD, FHD+ IR+ RGB Camera, and Windows 11 Pro

Lenovo Gen 13 ThinkPad X1 Carbon Touchscreen Laptop with Intel Ultra 7 265U Processor, 14" WUXGA 100% sRGB, 32GB DDR5 RAM, 1TB NVMe Performance SSD, FHD+ IR+ RGB Camera, and Windows 11 Pro

$1,589.00