Saturday, August 13, 2011

Re: Is there anyway that Vim can 'tag' or 'name' a window for future reference?

On 13/08/11 02:11, 张小潘 wrote:
> My ASCII graph is ruinned by the width limitation, I mean
>
> | | | | |
> | | | | |
> | 1 | 2 | 3 | 4 |
> | | | | |
> | | | | |
>
> On Fri, Aug 12, 2011 at 5:04 PM, Xiaopan Zhang<zhangxiaopan@gmail.com> wrote:
>> My requirement is a bit unique, so allow me to put a bit long story
>> here.
>>
>> I have two 24-inch dell monitors for regular coding work. I usually
>> run a full-window terminal window and then run a console vim inside
>> the terminal. Due to the enormous size of the terminal, I usually
>> split it vertically into 4 windows like following:
>>
>> | |
>> | | |
>> | |
>> | | |
>> | |
>> | | |
>> | |
>> | | |
>> | window 1 | window 2 | window 3
>> | window 4 |
>> | |
>> | | |
>> | |
>> | | |
>>
>> I developed a whole bunch of customized commands for VIM to edit files
>> in different windows, move files between windows, etc, etc. (If you
>> are interested, you can look at http://code.google.com/p/spititan/source/browse/trunk/configuration/vimrc).
>>
>> The problem I have is: the more I work on this window layout, the more
>> I feel that Vim lacks of facilities to identify windows, for example,
>> if I want to implement a customized command to exchange the files
>> between current window and window 1, I don't have a straightforward
>> way to identify the current window number, which is a major obstacle
>> to develop more sophisticated commands on this layout.
>>
>> Anybody has any idea?
>>
>> Thanks.
>
>
>

See :help winnr()

Windows are numbered from 1 at top left to (whatever many windows there
are) are bottom right.

- winnr() is the number of the current window
- winnr('$') is the number of windows (or the number of the last window)
in the current tab page
- winnr('#') is the number of the latest window accessed before the
current one

If you use several tab pages, see also :help tabpagewinnr()

Beware that :new :split :vsplit :sview etc. change the numbers of all
existing windows after the new one (unless, of course, the new window is
the last one). Also, moving the windows about with Ctrl-W followed by
one of HJKLRrx will of course change the window numbers.


Best regards,
Tony.
--
Walk softly and carry a megawatt laser.

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