Questions tagged [whitespace]

Question about how Vim handles non printable characters.

Filter by
Sorted by
Tagged with
151
votes
5answers
104k views

What's the simplest way to strip trailing whitespace from all lines in a file?

It's pretty common when programming or opening text files to encounter files with trailing whitespace at the end of a line. vim has a way to show this by setting the trail option in the listchars ...
7
votes
2answers
3k views

Vim doesn't use the correct indentation in Python files

I have encountered something that I have never seen before in Vim. While I was tentatively modifying some of the source code for software I've been planning to work on, I noticed vim was displaying ...
130
votes
6answers
139k views

Displaying tabs as characters

When I work on files in python, I sometimes mistake tabs for spaces and vice versa. Is there a way I can get Vim to display a character for a tab instead of a tab?
75
votes
5answers
16k views

How to join lines without producing a space?

The standard J command for joining lines replaces the newline character(s) with a space. It's useful when editing 'literature' but can be troublesome if I, say, edit a hex dump by hand if I forget to ...
13
votes
4answers
2k views

What is the rationale for \r and \n meaning different things in s command?

We all know that, when searching, \n is newline and \r is carriage return (^M), but when replacing \r is newline while \n is a null byte (^@). What is the origin of this asymmetry? Given that this ...
6
votes
1answer
677 views

How to show trailing spaces, while leaving tabs as they are?

I like the ability to show trailing whitespaces, so I have this setting. set list listchars=tab:\ \ ,trail:· I never use tabs (although I don't think tabs are bad, it's just a convention), but ...
2
votes
1answer
289 views

Stop vim from removing whitespace on save for diff files

I am currently trying to edit a git hunk file (a diff: .git/addp-hunk-edit.diff), and to say to git that a line containing whitespace is unchanged it needs to have (a line with a single space) as its ...
13
votes
2answers
2k views

How to differentiate visually the white spaces in vim? [duplicate]

My goal were to somehow make visible, if a whitespace is space, tab, or even newline (and, ideally, in case of newline I would be happy to see \r\n and \n differently). I am thinking to a similar ...
3
votes
3answers
442 views

Avoid spaces getting converted to tabs automatically during shift(>>)

I use 2 spaces as indentation. So I set shiftwidth using :set sw=2. However when I do the shift operator(>>) on a line twice, the indentation converts the 4 spaces automatically to a tab. So to ...