LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-04-2010, 08:27 AM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Rep: Reputation: 76
Vim: bringing the cursor to 1st char in current line (command mode).


Just in case someone can reply a silly question, I've quite forgotten the vi/vim command to bring the cursor to the 1st char in the current line. I do remember that for bringing it to EOL is '$'. And the help is so big I made up my mind to consul LQ firstly. Regards.
 
Old 12-04-2010, 08:38 AM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
The vim command cheat sheet says the command you seek is O (uppercase letter o).
 
Old 12-04-2010, 08:46 AM   #3
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
There must be some misunderstanding. I'm pressing ESC twice (just in case), then capital o, and, as a result, vim enters insert mode. Perhaps you speak about vi, and vi behaves unllike vim in this point.
 
Old 12-04-2010, 09:09 AM   #4
120
Member
 
Registered: Oct 2010
Posts: 46

Rep: Reputation: 9
Quote:
Originally Posted by stf92 View Post
There must be some misunderstanding. I'm pressing ESC twice (just in case), then capital o, and, as a result, vim enters insert mode. Perhaps you speak about vi, and vi behaves unllike vim in this point.
It's a zero, not a capital letter 'o', just like the vim cheat sheet listed above says ;-)

the MAN for vim clears up any of the o O 0 confusion:

-o[N] Open N windows stacked. When N is omitted, open one window for each file.

-O[N] Open N windows side by side. When N is omitted, open one window for each file.

Whilst zero is not mentioned, clearly upper case O is not character zero of the current line.

This may help more:
http://vimdoc.sourceforge.net/htmldo....html#help.txt

Last edited by 120; 12-04-2010 at 09:14 AM. Reason: mention MAN
 
Old 12-04-2010, 09:22 AM   #5
honeybadger
Member
 
Registered: Aug 2007
Location: India
Distribution: Slackware (mainly) and then a lot of others...
Posts: 855

Rep: Reputation: Disabled
To get to the first character of the current line its capital L.
'o' and 'O' are for creating new line below and above the current line. Just checked om my pc (vim 7.3) .
 
Old 12-04-2010, 09:28 AM   #6
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
Quote:
Originally Posted by 120 View Post
...
-o[N] Open N windows stacked. When N is omitted, open one window for each file.

-O[N] Open N windows side by side. When N is omitted, open one window for each file.
...
The lowercase letter o opens a new line below the current line and enters the insertmode.
The uppercase letter O begins a new line above the current line and enters the insertmode.

Markus

EDIT: SilverBack was faster than me

Last edited by markush; 12-04-2010 at 09:30 AM. Reason: inserted a smilie
 
Old 12-04-2010, 09:45 AM   #7
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
The classic command is ^ . The Home key also works here.

The L command here moves to the first character of the last line, same as G. There is almost certainly a difference between L and G. Any ideas?
 
Old 12-04-2010, 09:48 AM   #8
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
Quote:
Originally Posted by catkin View Post
...The L command here moves to the first character of the last line, same as G. There is almost certainly a difference between L and G. Any ideas?
Yes, G moves to the last line in the file (important: G with number "n" as an argument moves to the n'th line)
L moves to the first column in the last line of the current screen.

Markus
 
1 members found this post helpful.
Old 12-04-2010, 10:07 AM   #9
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by markush View Post
L moves to the first column in the last line of the current screen.
Thanks Markus; I should have tested with a bigger file but learned the L command
 
Old 12-04-2010, 10:49 AM   #10
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:
Originally Posted by bigrigdriver View Post
The vim command cheat sheet says the command you seek is O (uppercase letter o).
You misread the cheatsheet, that's a 0 (zero), not an uppercase O.
 
Old 12-04-2010, 12:46 PM   #11
120
Member
 
Registered: Oct 2010
Posts: 46

Rep: Reputation: 9
Quote:
Originally Posted by jlliagre View Post
You misread the cheatsheet, that's a 0 (zero), not an uppercase O.
Yep, I had already said that - way back up there /\ /\ /\ /\ /\
 
Old 12-04-2010, 02:42 PM   #12
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Quote:
Originally Posted by jlliagre View Post
You misread the cheatsheet, that's a 0 (zero), not an uppercase O.
bigrigdriver is not to blame. This is only one of the shortcomings of graphical user interfaces: zeroes confused with uppercase O, capital i confused with lowercase l (el).

Plus, why lowercase at all? In the old days of fortran, letters were all capitals, since this contributed readability for the data entry.

Last edited by stf92; 12-04-2010 at 02:47 PM.
 
Old 12-04-2010, 04:23 PM   #13
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:
Originally Posted by 120 View Post
Yep, I had already said that - way back up there /\ /\ /\ /\ /\
Sorry, I missed it. By the way, there is yet another vi command to do the same:
Code:
 1|
which means go to column 1 of the current line.
Of course 1 can be replaced by any column number.
 
Old 12-04-2010, 04:42 PM   #14
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:
Originally Posted by stf92 View Post
Plus, why lowercase at all? In the old days of fortran, letters were all capitals, since this contributed readability for the data entry.
I don't think so. Most readability studies show uppercase text is harder to read than lowercase one.
 
Old 12-05-2010, 03:23 AM   #15
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
I didn't know that, although I had found long texts in uppercase are awkward to read. But for short variable names, uppercase may be easier to read.
 
  


Reply

Tags
command_mode, eol, vim



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
Programing Question: Reading file line by line.. then char by char in each line adriumroot Programming 8 05-30-2010 01:55 AM
[SOLVED] How to get the cursor position line at the mid of the windows in vim? cola Linux - Newbie 5 03-28-2010 10:18 AM
How to make VIM change cursor shape when it is in inserting mode. since1993 Linux - Newbie 1 10-01-2009 06:59 PM
Bringing Up Command Line\prompt hondagetter Linux - General 3 09-04-2005 06:13 AM
51 characters only in the 1st Line of command line eggCover Linux - General 2 07-29-2004 01:28 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:31 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