擁抱自由,使用 linux !

在Linux底下真是太幸福了,有好多東西可以玩。想從windows解脫就是現在!

Mar-10-10

vim - Scrolling around

posted by Thomas

請自己記住

很基本,但常常忘記,都浪費很多時間up/down

應該用 CTRL+E / CTRL+Y 取代 或是 zz 也不錯!

自勉之…

http://vimdoc.sourceforge.net/htmldoc/usr_03.html

*03.7*	Scrolling around

The CTRL-U command scrolls down half a screen of text.  Think of looking
through a viewing window at the text and moving this window up by half the
height of the window.  Thus the window moves up over the text, which is
backward in the file.  Don't worry if you have a little trouble remembering
which end is up.  Most users have the same problem.
   The CTRL-D command moves the viewing window down half a screen in the file,
thus scrolls the text up half a screen.

				       +----------------+
				       | some text	|
				       | some text	|
				       | some text	|
	+---------------+	       | some text	|
	| some text	|  CTRL-U  --> |		|
	|		|	       | 123456		|
	| 123456	|	       +----------------+
	| 7890		|
	|		|	       +----------------+
	| example	|  CTRL-D -->  | 7890		|
	+---------------+	       |		|
				       | example	|
				       | example	|
				       | example	|
				       | example	|
				       +----------------+

To scroll one line at a time use CTRL-E (scroll up) and CTRL-Y (scroll down).
Think of CTRL-E to give you one line Extra.  (If you use MS-Windows compatible
key mappings CTRL-Y will redo a change instead of scroll.)

To scroll forward by a whole screen (except for two lines) use CTRL-F.  The
other way is backward, CTRL-B is the command to use.  Fortunately CTRL-F is
Forward and CTRL-B is Backward, that's easy to remember.

A common issue is that after moving down many lines with "j" your cursor is at
the bottom of the screen.  You would like to see the context of the line with
the cursor.  That's done with the "zz" command.

	+------------------+		 +------------------+
	| some text	   |		 | some text	    |
	| some text	   |		 | some text	    |
	| some text	   |		 | some text	    |
	| some text	   |   zz  -->	 | line with cursor |
	| some text	   |		 | some text	    |
	| some text	   |		 | some text	    |
	| line with cursor |		 | some text	    |
	+------------------+		 +------------------+

The "zt" command puts the cursor line at the top, "zb" at the bottom.  There
are a few more scrolling commands, see |Q_sc|.  To always keep a few lines of
context around the cursor, use the 'scrolloff' option.
Tags:
  1. Anonymous Said,

    好像还是page up page down比较快吧

  2. Thomas Said,

    呵,因為我習慣住是游標位置,page up 之後 我還要移動上下左右到我想看的code附近,ctrl+e 就可以不動游標上下移動頁面半頁,ctrl+u/d 太多了,zz 也是不錯,可以把想看的東西移到中間,所以善用ctrle/y/u/d 就可以少很多 up/down…

Add A Comment