LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Vim: bringing the cursor to 1st char in current line (command mode). (https://www.linuxquestions.org/questions/linux-newbie-8/vim-bringing-the-cursor-to-1st-char-in-current-line-command-mode-848316/)

stf92 12-04-2010 08:27 AM

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.

bigrigdriver 12-04-2010 08:38 AM

The vim command cheat sheet says the command you seek is O (uppercase letter o).

stf92 12-04-2010 08:46 AM

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.

120 12-04-2010 09:09 AM

Quote:

Originally Posted by stf92 (Post 4180447)
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

honeybadger 12-04-2010 09:22 AM

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) :).

markush 12-04-2010 09:28 AM

Quote:

Originally Posted by 120 (Post 4180459)
...
-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 ;)

catkin 12-04-2010 09:45 AM

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?

markush 12-04-2010 09:48 AM

Quote:

Originally Posted by catkin (Post 4180486)
...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

catkin 12-04-2010 10:07 AM

Quote:

Originally Posted by markush (Post 4180488)
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 :)

jlliagre 12-04-2010 10:49 AM

Quote:

Originally Posted by bigrigdriver (Post 4180440)
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.

120 12-04-2010 12:46 PM

Quote:

Originally Posted by jlliagre (Post 4180559)
You misread the cheatsheet, that's a 0 (zero), not an uppercase O.

Yep, I had already said that - way back up there /\ /\ /\ /\ /\

stf92 12-04-2010 02:42 PM

Quote:

Originally Posted by jlliagre (Post 4180559)
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.

jlliagre 12-04-2010 04:23 PM

Quote:

Originally Posted by 120 (Post 4180656)
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.

jlliagre 12-04-2010 04:42 PM

Quote:

Originally Posted by stf92 (Post 4180737)
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.

stf92 12-05-2010 03:23 AM

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.


All times are GMT -5. The time now is 08:47 PM.