Showing results for 
Search instead for 
Did you mean: 

vi tab/space

Go to solution
Super Advisor

vi tab/space

vi Editor

I view a text file and I copy some text lines.

Then I vi other file and try to paste the copied text lines. But it includes some tabs or spaces at the beginning of each line and the structure is TOTALLY altered. This does not happen with linux vi (just to mention another case).

how can I avoid the inclusion of this tabs/spaces at the beginning of each copied line?
James R. Ferguson
Acclaimed Contributor

Re: vi tab/space


I suspect that your copy buffer has the leading whitespace because of how you created the it. In the absence of specific details of how and from where you copy-and-paste (e.g. from a Windows PC?) it is difficult to answer.



Re: vi tab/space

It's possible your vi is running in 'autoindent' mode, which will automatically intent new lines to match the previous line. This is very useful for interactive editing, but causes problems for copy+paste.

Before pasting, try running this in the destination vi: ":set noai" (without the quotes).

autoindent seems to be the default on HP-UX vi. Linux doesn't have a standard 'vi', but on most of them, 'ai' is not the default.

BTW, if you want to read an entire file into vi, you don't need to use copy/paste, you can simply use ":r /path/to/file". This also avoids other copy+paste issues, like tabs being converted to spaces.
Super Advisor

Re: vi tab/space

BINGO River!

The ":set noai" solved my problem.