{"id":36,"date":"2014-07-20T00:00:27","date_gmt":"2014-07-19T22:00:27","guid":{"rendered":"http:\/\/kurt.www.pinboard.jp\/blog\/?p=36"},"modified":"2014-07-22T00:05:09","modified_gmt":"2014-07-21T22:05:09","slug":"move-around-the-screen","status":"publish","type":"post","link":"http:\/\/kurt.www.pinboard.jp\/blog\/kurt\/36\/","title":{"rendered":"move around the screen"},"content":{"rendered":"<p>The most basic commands to move up and down in vim are <span style=\"color: #008000;\">j<\/span> and <span style=\"color: #008000;\">k<\/span>. They are fine if you want to move line by line, but not if you want to<!--more--> move in larger steps. There are various commands to scroll the screen in bigger chunks.<\/p>\n<table>\n<tbody valign=\"top\">\n<tr>\n<td style=\"background-color:lightyellow; color: green;\">CTRL-b<\/td>\n<td>\u00a0<span style=\"color: #008000;\">PgUp<\/span><\/td>\n<td>\u00a0<span style=\"color: #008000;\">SHIFT-Up<\/span><\/td>\n<td>scroll one screen backward (up)<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:lightyellow; color: green;\">CTRL-f<\/td>\n<td>\u00a0<span style=\"color: #008000;\">PgDown<\/span><\/td>\n<td>\u00a0<span style=\"color: #008000;\">SHIFT-Down<\/span><\/td>\n<td>scroll one screen forward (down)<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color: #008000;\">CTRL-u<\/span><\/td>\n<td><\/td>\n<td><\/td>\n<td>scroll half a screen backward (up)<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color: #008000;\">CTRL-d<\/span><\/td>\n<td><\/td>\n<td><\/td>\n<td>scroll half a screen forward (down)<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color: #008000;\">CTRL-y<\/span><\/td>\n<td><\/td>\n<td><\/td>\n<td>scroll one line backward (up)<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color: #008000;\">CTRL-e<\/span><\/td>\n<td><\/td>\n<td><\/td>\n<td>scroll one line forward (down)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>I have memorized <span style=\"color: #008000;\">CTRL-f<\/span> and <span style=\"color: #008000;\">CTRL-b<\/span>, that&#8217;s sufficient for me. If I want to move half screens or single lines I do it differently, using a set of commands which I know anyways because they are very handy in certain situations.<\/p>\n<p>Very often I want to quickly move the cursor to the top, bottom or middle of the current screen and then use <span style=\"color: #008000;\">j<\/span> and <span style=\"color: #008000;\">h<\/span> to go a certain line. There are three very handy commands for this.<\/p>\n<table>\n<tbody valign=\"top\">\n<tr>\n<td style=\"background-color:lightyellow; color: green;\">H<\/td>\n<td>move the cursor to the top of the current screen (<em>H<\/em>ead)<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:lightyellow; color: green;\">M<\/td>\n<td>move the cursor to the middle of the current screen (<em>M<\/em>iddle)<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:lightyellow; color: green;\">L<\/td>\n<td>move the cursor to the bottom of the current screen (<em>L<\/em>ast)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>But when I&#8217;m writing scripts, I usually want the cursor to stay on the line it is at when scrolling up or down. Here a few z commands come in handy.<\/p>\n<table>\n<tbody valign=\"top\">\n<tr>\n<td style=\"background-color:lightyellow; color: green;\">zt<\/td>\n<td>move the current line to the top of the screen, leaving the cursor on the current line (<em>t<\/em>op)<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:lightyellow; color: green;\">zz<\/td>\n<td>move the current line to the center of the screen, leaving the cursor on the current line (<em>z<\/em>enter)<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:lightyellow; color: green;\">zb<\/td>\n<td>move the current line to the bottom of the screen, leaving the cursor on the current line (<em>b<\/em>ottom)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>These commands leave the cursor exactly where it was in the line. There is an equivalent set of z commands which additionally move the cursor to the first non-blank character of the line. But quite honestly, if I really want to do that there are other ways to achieve it and I rather remember fewer commands and type a little bit more than trying to remember every possibility and get confused.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The most basic commands to move up and down in vim are j and k. They are fine if you want to move line by line, but not if you want to<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[7],"_links":{"self":[{"href":"http:\/\/kurt.www.pinboard.jp\/blog\/wp-json\/wp\/v2\/posts\/36"}],"collection":[{"href":"http:\/\/kurt.www.pinboard.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/kurt.www.pinboard.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/kurt.www.pinboard.jp\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/kurt.www.pinboard.jp\/blog\/wp-json\/wp\/v2\/comments?post=36"}],"version-history":[{"count":6,"href":"http:\/\/kurt.www.pinboard.jp\/blog\/wp-json\/wp\/v2\/posts\/36\/revisions"}],"predecessor-version":[{"id":65,"href":"http:\/\/kurt.www.pinboard.jp\/blog\/wp-json\/wp\/v2\/posts\/36\/revisions\/65"}],"wp:attachment":[{"href":"http:\/\/kurt.www.pinboard.jp\/blog\/wp-json\/wp\/v2\/media?parent=36"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/kurt.www.pinboard.jp\/blog\/wp-json\/wp\/v2\/categories?post=36"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/kurt.www.pinboard.jp\/blog\/wp-json\/wp\/v2\/tags?post=36"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}