2
:set lcs=precedes:^,eol:#

I want to insert a character ^ at the beginning of each line.
Here is the result of :set lcs=precedes:^,eol:#.

enter image description here

Why lcs=precedes:^ can't add a character ^ in the article such as the following?

enter image description here

2 Answers 2

4

To add ^ at the beginning of each line use

:%s/^/^ /

For a range of lines use:

Ex. Lines 10-20 - :10,20s/^/^ /

1
  • i want to make set list take the same effect such as ** :%s/^/^ /** do.
    – showkey
    Commented Jan 28, 2017 at 6:59
2

As per VIM Help on listchars, precedes:^ only results in ^ showing at the beginning of the line if "'wrap' is off and there is text preceding the character visible in the first column."

So precedes provides an indication that the first character shown on the screen is not the first character in the line. In terms of listchars options, it is the start-of-line equivalent of extends, which indicates that the line continues beyond the right of the screen when wrap is off.

There is no start-of-line equivalent of eol – that is, an option that would show a virtual character preceding the first character in the line. There is no need for that as you always know where the line starts (at the left edge of the screen, unless precedes indicates otherwise), while you don't always know where the line ends if you have trailing whitespace.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.