Questions tagged [whitespace]

Question about how Vim handles non printable characters.

Filter by
Sorted by
Tagged with
9
votes
4answers
2k views

SpecialKey foreground color w/ cursorline set

In this Q&A, it's observed that there is a highlight group for CursorLineNr, which applies to the line number for the cursor line when set cursorline is on. I notice that using cursorline also ...
5
votes
2answers
6k views

delete entire line after first whitespace on every line

I have a file (around 1.6 million lines) which formatted like this: -0.00697468 0 -1.95966e-49 101325 -3.06381 -0.00697468 0 -1.95966e-49 101325 -3.06381 -0.00697468 0 -1.95966e-49 101325 -3....
3
votes
0answers
3k views

Any way to display *all* characters?

So, I got it that Vim has no option to display all characters (including whitespace and CR and LF distinctly) I already saw the question How to Display Hidden Characters in vim? and others on ...
6
votes
1answer
1k views

What does vim consider a paragragh?

Suppose I have the following piece of code through which I would like to navigate ===>Cursor is here and when I press { SomeTest { line1 line2 line3 line4 ...
1
vote
1answer
634 views

Fix spacing with vim

I would like to fix only spacing in badly formatted C/C++ source code. The Vim command = fixes only indentation. Utility indent is not suitable, because it reformats totally all source code, but want ...
3
votes
3answers
655 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 ...
4
votes
1answer
2k views

How does vimscript know which buffer these buffer-local variables use?

Consider the following vimscript: function! DecideWhetherToStrip() let l:search = @/ " Check if a file being opened has trailing spaces in the first place. let b:dostrip = !search('\s\+$',...
18
votes
3answers
1k views

Tabs for indentation, spaces for alignment

I am trying to make vim auto indent with tabs, and align with whitespaces, but actually, vim indent with tabs and fill the alignment with tabs + white spaces. Vim does it : (each block is a tab) { &...
3
votes
1answer
433 views

How to skip over indentation whitespace with horizontal motion?

I have a file that uses 4-space indentation. By default, when I move horizontally, Vim moves over those spaces one by one. How can I configure Vim so that it moves 4 spaces horizontally when moving ...
44
votes
2answers
46k views

How to indent as spaces instead of tab?

I am coding some html templates in JADE files. I want to auto indent code with spaces instead of tab. I tried shiftwidth=2, tabstop=2, but no matter what, it's still indents using tabs instead of ...
20
votes
3answers
2k views

How can I make Vim position the cursor at the start of a tab character instead of the end?

Open an empty buffer and insert a tab character then exit to normal mode. When you place the cursor (normal mode) on the tab it will be at the right side of the whitespace. I'm looking for a way so ...
2
votes
3answers
5k views

How can I remove additional whitespace in the middle of line?

I know how to remove trailing white spaces at the end of lines. Does anyone know how to remove white spaces in the middle of a line? The white space I mean is before tab and after tab characters. For ...
12
votes
3answers
20k views

How to split a line into multiple lines efficiently?

I've been receiving logged data in a text file that is just one long line with each value separated by a space. Is there a command or set of commands that will split one line into multiple lines?
13
votes
2answers
3k 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 ...
6
votes
1answer
390 views

equalprg to use for Python

Python is whitespace dependent, and it can't be totally autoindented for that reason, but there are a lot of extra stuff that should be possible to do automatically to comply with PEP8. Things like ...
8
votes
1answer
193 views

Running cleanup commands only for edited lines possible?

Referring to clean-up tasks like (but not limited to) the ones detailed in these questions: Re-indenting badly indented code What's the simplest way to strip trailing whitespace from all lines in ...
175
votes
5answers
135k 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 ...
89
votes
5answers
21k 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 ...
166
votes
8answers
186k 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?

1
2