(Change <tt> to <code>, perhaps also minor tweak.)
Line 3:
Line 3:
|previous=1623
|previous=1623
|next=1625
|next=1625
−
|created=May 4, 2009
+
|created=2009
|complexity=basic
|complexity=basic
|author=Tonymec
|author=Tonymec
Line 20:
Line 20:
</pre>
</pre>
−
The former will act on the dollar sign without using it as a count; the latter counts <tt>$</tt> as the number of lines in the current buffer, and goes to the very last window if the "<tt>$-1</tt>" count exceeds the number of windows in the current or only tab page.
+
The former will act on the dollar sign without using it as a count; the latter counts <code>$</code> as the number of lines in the current buffer, and goes to the very last window if the "<code>$-1</code>" count exceeds the number of windows in the current or only tab page.
;This works
;This works
−
<tt>:exe winnr('$') - 1 'wincmd w'</tt>
+
<code>:exe winnr('$') - 1 'wincmd w'</code>
==References==
==References==
Line 34:
Line 34:
I'd like to see a use case for this, that merits its becoming a proper tip. It's a good observation, though. ([[User:Spiiph|Spiiph]] 23:55, 28 July 2009 (UTC))
I'd like to see a use case for this, that merits its becoming a proper tip. It's a good observation, though. ([[User:Spiiph|Spiiph]] 23:55, 28 July 2009 (UTC))
−
:If you have no more than a handful of split-windows, you don't need this tip because you can tell at a glance the number of the wanted window (unless, of course, you want to go to the nth-from-last window from ''a mapping or a script''). But if you have a lot of windows (in my current gvim session there are 21, opened "[[Window zooming convenience|Rolodex style]]" with <tt>:set wh=9999 wmh=0</tt>), you'd need a better counting-at-a-glance ability than most people have, even to be able to type the right number at the keyboard. But we can, for instance, create the following to always go to the second-last window by hitting F12:<pre> :map <F12> :exe winnr('$') - 1 'wincmd w'<CR></pre>--[[User:Tonymec|Tonymec]] 02:55, 5 August 2009 (UTC)
+
:If you have no more than a handful of split-windows, you don't need this tip because you can tell at a glance the number of the wanted window (unless, of course, you want to go to the nth-from-last window from ''a mapping or a script''). But if you have a lot of windows (in my current gvim session there are 21, opened "[[Window zooming convenience|Rolodex style]]" with <code>:set wh=9999 wmh=0</code>), you'd need a better counting-at-a-glance ability than most people have, even to be able to type the right number at the keyboard. But we can, for instance, create the following to always go to the second-last window by hitting F12:<pre> :map <F12> :exe winnr('$') - 1 'wincmd w'<CR></pre>--[[User:Tonymec|Tonymec]] 02:55, 5 August 2009 (UTC)
created 2009 · complexity basic · author Tonymec · version 7.0
It's obvious once you're shown it, so here are a few examples (to go to the second-last window):
This does not work
$-1^Ww
:$-1wincmd w
The former will act on the dollar sign without using it as a count; the latter counts $ as the number of lines in the current buffer, and goes to the very last window if the "$-1" count exceeds the number of windows in the current or only tab page.
I'd like to see a use case for this, that merits its becoming a proper tip. It's a good observation, though. (Spiiph 23:55, 28 July 2009 (UTC))
If you have no more than a handful of split-windows, you don't need this tip because you can tell at a glance the number of the wanted window (unless, of course, you want to go to the nth-from-last window from a mapping or a script). But if you have a lot of windows (in my current gvim session there are 21, opened "Rolodex style" with :set wh=9999 wmh=0), you'd need a better counting-at-a-glance ability than most people have, even to be able to type the right number at the keyboard. But we can, for instance, create the following to always go to the second-last window by hitting F12: