Vim Recall繁體中文

Send text to a shell tool

:%write !wc -l

Example

Normal mode. Lines: alpha, beta. Shell tool wc is installed.

Before
alpha
beta
  1. :%write !wc -l<CR> wc reports 2 lines · buffer unchanged
Details & Vim help

Send a range to a command’s standard input without replacing the buffer.

Measure or inspect text using an external tool.

The ! command runs a shell program; it is different from :write! file. This example assumes wc is installed. It does not save the buffer to its current file or clear the modified flag.

Buffer text stays unchanged; wc reports 2 lines in command output.

Try it in Vim

  1. Run :%write !wc -l<CR> to count all buffer lines.
  2. Read the command output.
  3. Return to editing when Vim prompts.