LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-21-2005, 08:16 PM   #1
penguin_powered
LQ Newbie
 
Registered: Apr 2004
Location: Houston, Texas
Distribution: Linux Mint 13, MATE 32-bit edition
Posts: 24

Rep: Reputation: 15
Question vim and vi editing question


For the most part, I love using vim and vi...but...sometimes I feel like I'm stuck in an old-fashioned line editor rather than a full-screen editor.

Why can't I just hit Del a few times at the end of a line till the line below comes up and joins it,
or be on the 1st character of the line below and backspace until the line moves up to the end of the preceding line??

I tried cutting and pasting and vim kept pasting the line right back on line 2 instead of at the end of line 1, even though I had the cursor positioned at the end of line 1 when I pasted.

This is the one thing in vi that really bugs me. It should be so simple. Am I wrong in feeling like I'm in a line editor instead of a full-screen editor? I hope I'm missing something about vi and vim, or else it's time for me to make a serious effort to learn emacs.

Thanks in advance!
 
Old 07-21-2005, 08:26 PM   #2
Raspis21
Member
 
Registered: Jun 2003
Posts: 33

Rep: Reputation: 15
HI penguin_powered,

I just tried your scenario, and so long as I was in insert mode, I was able to paste at the end of a line (I used the center click function of X) If I was not in insert mode, I found it added to the next line while entering insert mode for me. I don't know if it is just my version, or if mine is set up differently to yours. I use VIM - Vi IMproved 6.3 and it works fine.

Hope it helps,

Raspis
 
Old 07-22-2005, 09:14 AM   #3
synaptical
Senior Member
 
Registered: Jun 2003
Distribution: Mint 13/15, CentOS 6.4
Posts: 2,020

Rep: Reputation: 48
my understanding is that if you cut an entire line, you can only paste it as a new line. if you cut part of a line, you can paste it as part of another line at the cursor. but i haven't delved into a lot of advanced methods, and vi/vim is very powerful so it's probably possible somehow. if you search google you could probably find a lot of tutorials, e.g. this one on Vi. http://docs.freebsd.org/44doc/usd/12.vi/paper.html
 
Old 07-22-2005, 11:10 AM   #4
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Quote:
For the most part, I love using vim and vi...but...sometimes I feel like I'm stuck in an old-fashioned line editor rather than a full-screen editor.
Try the good old "ed", and then you'll see the difference between a line editor and a full-screen one
Quote:
Why can't I just hit Del a few times at the end of a line till the line below comes up and joins it,
or be on the 1st character of the line below and backspace until the line moves up to the end of the preceding line??
Because, vi has never behaved that way, and changing it would break compatibility and habits.
Joining lines is done under vi with the J command.
Quote:
I tried cutting and pasting and vim kept pasting the line right back on line 2 instead of at the end of line 1, even though I had the cursor positioned at the end of line 1 when I pasted.
How are you cutting and pasting ?
cutting is done under vi with the "y<something>" command, and pasting with "p" or "P".
The rest is not vi cut/paste but interaction with vi in insert mode in your terminal emulator and X. If your cut-buffer starts with a new-line, there's nothing to prevent vi accepting it.
Quote:
This is the one thing in vi that really bugs me. It should be so simple. Am I wrong in feeling like I'm in a line editor instead of a full-screen editor?
I think so.
Quote:
I hope I'm missing something about vi and vim, or else it's time for me to make a serious effort to learn emacs.
emacs sucks, but that is just my personal opinion and I respect emacs users.
 
Old 07-24-2005, 05:39 PM   #5
eddiebaby1023
Member
 
Registered: May 2005
Posts: 378

Rep: Reputation: 33
To join two lines, put your cursor on the first one and type J.

If you want to paste a line before the current line, use P instead of p. Most command do different things if you use the capital version of the command (I inserts at the beginning if the line, i inserts at the cursor; A appends at the end of line, a appends after the cursor).

vi is a fantastic editor, but there are many commands to learn before you can use it efficiently. If you're like me you'll still be learning new things about it after many years of use. Executing commands from named buffers is a great way to do complicated global substitutions.
 
Old 07-24-2005, 05:43 PM   #6
eddiebaby1023
Member
 
Registered: May 2005
Posts: 378

Rep: Reputation: 33
Missed your attempt to join one line to another with cut'n'paste. Put your cursor at the start of the text to cut and instead of "dd", use "d$" to delete to end of line. Then go to the end of the line you want to add to and hit 'p'. If you cut by deleting the whole line, the paste will work by inserting a whole line.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
VIM: editing files via ftp robertmarkbram Linux - Software 2 10-17-2004 01:41 AM
vim question blackzone Linux - Newbie 2 09-10-2004 10:04 AM
vi/vim question kiley_rodgers Slackware 1 06-18-2003 09:15 AM
Vim editing newbie needs help! andym Linux - Software 1 04-16-2003 03:59 AM
editing two files in vim qanopus Linux - Software 2 12-28-2002 08:56 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration