Saturday, July 30, 2011

Re: How to make cursor not always at the last line

On 30/07/11 07:26, Rice wrote:
> Hi, I am writing code and reading source code with vim. When I am
> reading the source code, the cursor always stays at the last line.
> What I want is to make the cursor always stays at the middle of the
> screen when I am pressing "j", so that I can have a larger view of the
> code that below the cursor. It seems that I achieve it by posting the
> following line in the .vimrc
> set so=8
> which means that the cursor always keep the distance of 8 lines from
> the bottom.
>
> However, when I am do some coding, it does not wok. I found that I am
> always at the last line to do my coding, which makes me feel annoyed.
> Of course, I can press "zz" to push the current editing line at the
> middle of the screen. But, it is just a boring work when i go to the
> last line and press "zz" again and again.
>
> So is there any ways not to keep the cursor at the last line when I am
> coding, just like after pressing "zz" or something similar.
>

Well, if you are in a file with lots of lines both above and below the
cursor, then ":set so=999" (or some other big value) should keep the
cursor near the middle of the window. However:

* It is not possible to make the first line in the file start lower than
the top of the window.

* When 'wrap' is on, the top of the window will always be at the start
of a line (which may occupy several lines on the screen), except perhaps
if the current line is bigger than the whole window (in which case
either or both of the start and end of the current line may overflow the
boundaries of the current window).

* When near the bottom of the file, Vim will let the cursor go down once
the last line in the file is fully inside the window (i.e., 'scrolloff'
doesn't count anything after the last existing line in the file).


Best regards,
Tony.
--
People need good lies. There are too many bad ones.
-- Bokonon, "Cat's Cradle" by Kurt Vonnegut, Jr.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment