WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: In vi why do blank lines copy as tabbed lines?  (Read 2393 times)

Offline bigpcman

  • Hero Member
  • *****
  • Posts: 719
In vi why do blank lines copy as tabbed lines?
« on: May 31, 2010, 06:40:16 PM »
I'm using tc3alpha5.

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

see attached pic


« Last Edit: March 28, 2023, 01:24:59 AM by Rich »
big pc man

Offline maro

  • Hero Member
  • *****
  • Posts: 1228
Re: In vi why do blank lines copy as tabbed lines?
« Reply #1 on: May 31, 2010, 07: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'
« Last Edit: May 31, 2010, 07:19:08 PM by maro »

Offline bigpcman

  • Hero Member
  • *****
  • Posts: 719
Re: In vi why do blank lines copy as tabbed lines?
« Reply #2 on: May 31, 2010, 09:05:03 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'

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

Offline roberts

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 7361
  • Founder Emeritus
Re: In vi why do blank lines copy as tabbed lines?
« Reply #3 on: May 31, 2010, 11:08:18 PM »
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.
10+ Years Contributing to Linux Open Source Projects.

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11044
Re: In vi why do blank lines copy as tabbed lines?
« Reply #4 on: June 01, 2010, 03:17:01 AM »
Nano's wrapping can be toggled in the config file, or with the -w option. :)
The only barriers that can stop you are the ones you create yourself.