Tiny Core Base > TCB Talk

In vi why do blank lines copy as tabbed lines?

(1/1)

bigpcman:
I'm using tc3alpha5.

I did a copy and paste using high light copy and wheel mouse button paste.

see attached pic


maro:
That is a problem of the 'vi' applet from BusyBox. I'd suggest you raise a bug there. It's nothing new in TC 3.x and has happened to me ever since I can remember (also with other distributions using BusyBox).

I have two different ways of dealing with this:
* Using a proper 'VI' by installing the vim extension (and either not forgetting to use 'vim' instead of 'vi' or changing the symbolic link), or
* Using something like cat > FILE (or cat >> FILE) and after pasting the text the critical thing is to enter 'Ctrl-D' to end the entry.This way the indentation stays correct, but 'tab' characters are getting replaced by spaces either way.



Edit: I guess you'll find that your seemingly empty lines are containing a 'tab' character and that leads to the indenting. Here are a couple of test cases that produce faulty results when copy / pasting them into a 'vi' session: printf '1\n\t\n23\n\t\n456\n' or printf '1\n\t23\n456\n'

bigpcman:

--- Quote from: maro on May 31, 2010, 04:00:51 PM ---That is a problem of the 'vi' applet from BusyBox. I'd suggest you raise a bug there. It's nothing new in TC 3.x and has happened to me ever since I can remember (also with other distributions using BusyBox).

I have two different ways of dealing with this:
* Using a proper 'VI' by installing the vim extension (and either not forgetting to use 'vim' instead of 'vi' or changing the symbolic link), or
* Using something like cat > FILE (or cat >> FILE) and after pasting the text the critical thing is to enter 'Ctrl-D' to end the entry.This way the indentation stays correct, but 'tab' characters are getting replaced by spaces either way.



Edit: I guess you'll find that your seemingly empty lines are containing a 'tab' character and that leads to the indenting. Here are a couple of test cases that produce faulty results when copy / pasting them into a 'vi' session: printf '1\n\t\n23\n\t\n456\n' or printf '1\n\t23\n456\n'

--- End quote ---

At just 60K nano seems to do the job. copy / paste work just as they should.

roberts:
Normally I don't type lines like that!  ;D
But what you are seeing is the classic staircase effect.
It is caused by having the autoindent feature set for busybox vi. It is on by default.

So when you want to paste text with existing indentation and want to avoid the "staircase" effect, just issue

:set noautoindent

Before you paste and reenable with

set autoindent

Caution when using nano for possible word wrap which will break long lines, a code killer.

curaga:
Nano's wrapping can be toggled in the config file, or with the -w option. :)

Navigation

[0] Message Index

Go to full version