Using z in vim

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Using z in vim

Ven Tadipatri
Hi,
   There should be a way to make the current line that you're on scroll to the top of the screen right?
I've googled for "vim scrolling" or "vim z". Apparently Google's search is not case sensitive.
   Hitting z twice will make the current line that you're on scroll to the center of the screen.
But I don't want that. I want to make the current line that I'm on scroll to the TOP of the screen.
Is that possible?
  The z key seems a bit overloaded, because zf will create a fold, zo opens it, zc will close a fold, etc.
I vaguely remember hitting some key combination to get this feature of "scrolling to the top of the screen
while still staying on the same line".
  On a somewhat related note, I notice that ZZ will quit. But isn't that exactly what :wq does?
What's the difference?

Thanks,
Ven

--
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
Reply | Threaded
Open this post in threaded view
|

Re: Using z in vim

Taylor Hedberg
You want `zt`.

signature.asc (853 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Using z in vim

Guido Van Hoecke-2
In reply to this post by Ven Tadipatri
On Tue, Feb 21, 2012 at 17:39, Ven Tadipatri <[hidden email]> wrote:
> Hi,
>    There should be a way to make the current line that you're on scroll to
> the top of the screen right?
> I've googled for "vim scrolling" or "vim z". Apparently Google's search is
> not case sensitive.

No need to google, ask vim:

:help z

shows section 2.5 5 Commands starting with 'z'

/redraw shows z<CR>, zt, z- etc..  etc..

I hope this helps,


Guido

--
The aim of science is to seek the simplest explanations of complex
facts.  Seek simplicity and distrust it.
                -- Whitehead.

--
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
Reply | Threaded
Open this post in threaded view
|

Re: Using z in vim

Tim Chase
In reply to this post by Ven Tadipatri
On 02/21/12 10:39, Ven Tadipatri wrote:
> But I don't want that. I want to make the current line that I'm on scroll
> to the TOP of the screen.

You want either "zt" or "z<cr>" depending on whether you want to
reset the cursor to the first column:

   :help zt
   :help z<CR>

>    On a somewhat related note, I notice that ZZ will quit. But isn't that
> exactly what :wq does?

One character :)

The both perform identically.  I generally prefer building up
what I want to do by combining elements, so I tend to think
progressively in terms of "(w)rite (q) (a)ll really(!)" and then
drop in the respective elements into my command-prompt.  I only
use "ZZ" when playing VimGolf.com which saves me one extra
character. :)

-tim


--
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
Reply | Threaded
Open this post in threaded view
|

Re: Using z in vim

Benjamin R. Haskell-8
In reply to this post by Ven Tadipatri
On Tue, 21 Feb 2012, Ven Tadipatri wrote:

> Hi,
>
> There should be a way to make the current line that you're on
> scroll to the top of the screen right?  I've googled for "vim
> scrolling" or "vim z". Apparently Google's search is not case
> sensitive.

Use Vim's built-in help:

:help z

gets you the list of all commands starting with z.  Similarly for:

:help g
:help CTRL-W
:help [

(Those are the ones that have the most "overloaded" behavior.)


> On a somewhat related note, I notice that ZZ will quit. But isn't that
> exactly what :wq does?  What's the difference?

ZZ is faster and easier to type.  (Hold shift with right pinky, tap 'z'
twice with left.)  Also, it's equivalent to :x, not :wq.  The help for
:x explains:

"""
Like ":wq", but write only when changes have been made.
"""

--
Best,
Ben

--
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
Reply | Threaded
Open this post in threaded view
|

Re: Using z in vim

Tony Mechelynck
In reply to this post by Tim Chase
On 21/02/12 17:59, Tim Chase wrote:

> On 02/21/12 10:39, Ven Tadipatri wrote:
>> But I don't want that. I want to make the current line that I'm on scroll
>> to the TOP of the screen.
>
> You want either "zt" or "z<cr>" depending on whether you want to reset
> the cursor to the first column:
>
> :help zt
> :help z<CR>
>
>> On a somewhat related note, I notice that ZZ will quit. But isn't that
>> exactly what :wq does?
>
> One character :)
>
> The both perform identically. I generally prefer building up what I want
> to do by combining elements, so I tend to think progressively in terms
> of "(w)rite (q) (a)ll really(!)" and then drop in the respective
> elements into my command-prompt. I only use "ZZ" when playing
> VimGolf.com which saves me one extra character. :)
>
> -tim
>
>

They do *not* perform identically if the current window isn't modified:
in that case, ZZ wil close the current window (and exit Vim if it's the
last window with the possible exception of a help window), :wq will
write it first even if unmodified.

ZZ can be regarded as faster even than :x (with which it _is_
synonymous) in that it uses a single key twice with no change in shift
status between them.


Best regards,
Tony.
--
And so, men, we can see that human skin is an even more complex and
fascinating organ than we thought it was, and if we want to keep it
looking good, we have to care for it as though it were our own.  One
approach is to undergo a painful surgical procedure wherein your skin
is turned inside-out, so the young cells are on the outside, but then
of course you have the unpleasant side effect that your insides
gradually fill up with dead old cells and you explode.  So this
procedure is pretty much limited to top Hollywood stars for whom
youthful beauty is a career necessity, such as Elizabeth Taylor and
Orson Welles.
                -- Dave Barry, "Saving Face"

--
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