sheetal | 10 Aug 2012 10:00
Picon

moving tab pages using maps

Hello everyone,

What i want to do is map some key<A-S-j/k> such that when ever i press the key i want the current tabpage to be
moved previous to a tab/after the next tab and still keep my cursor in the current tab only. 

All I wanted to know is this possible and if so, then how can get the current tabpage no.

--

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

Marcin Szamotulski | 10 Aug 2012 14:30
Picon
Gravatar

Re: moving tab pages using maps

On 01:00 Fri 10 Aug     , sheetal wrote:
> Hello everyone,
> 
> What i want to do is map some key<A-S-j/k> such that when ever i press the key i want the current tabpage to be
moved previous to a tab/after the next tab and still keep my cursor in the current tab only. 
> 
> All I wanted to know is this possible and if so, then how can get the current tabpage no.
> 
> -- 
> 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

Hi,

It is possible and quite easy:

map <A-S-j> :tabm +1<CR>
map <A-S-k> :tabm -1<CR>

Though I am not sure if I understand you correctly when you write 'keep my
cursor in the current tab'. If you accidentally mean to move to the tab that
replaced the current on in the tab list use this:
map <A-S-j> :tabm +1<bar>tabp<CR>
map <A-S-k> :tabm -1<bar>tabn<CR>

Best,
Marcin

--

-- 
(Continue reading)

John Beckett | 11 Aug 2012 01:21
Picon

RE: moving tab pages using maps

Marcin Szamotulski wrote:
> It is possible and quite easy:
>
> map <A-S-j> :tabm +1<CR>
> map <A-S-k> :tabm -1<CR>

I don't think that would work. A mapping to move the current tab
is included here:

http://vim.wikia.com/wiki/Using_tab_pages

John

--

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

sheetal | 17 Aug 2012 08:46
Picon

Re: moving tab pages using maps

On Friday, August 10, 2012 6:00:02 PM UTC+5:30, coot_. wrote:
> On 01:00 Fri 10 Aug     , sheetal wrote:
> 
> > Hello everyone,
> 
> > 
> 
> > What i want to do is map some key<A-S-j/k> such that when ever i press the key i want the current tabpage to be
moved previous to a tab/after the next tab and still keep my cursor in the current tab only. 
> 
> > 
> 
> > All I wanted to know is this possible and if so, then how can get the current tabpage no.
> 
> > 
> 
> > -- 
> 
> > 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
> 
> 
> 
> Hi,
> 
> 
> 
(Continue reading)

ping | 10 Aug 2012 14:48
Picon

Re: moving tab pages using maps

On 8/10/2012 4:00 AM, sheetal wrote:
> Hello everyone,
>
> What i want to do is map some key<A-S-j/k> such that when ever i press the key i want the current tabpage to be
moved previous to a tab/after the next tab and still keep my cursor in the current tab only.
>
> All I wanted to know is this possible and if so, then how can get the current tabpage no.
>

forgot where I got this (mostly from vim plugin website)
but this provide what you are asking for:

  function! MoveCurrentTab(value)
    if a:value == 0
      return
    endif
    let move = a:value - 1
    let move_to = tabpagenr() + move
    if move_to < 0
      let move_to = 0
    endif
    exe 'tabmove '.move_to
  endfunction

  map <silent> <M-left> :call MoveCurrentTab(-1)<Esc>
  map <silent> <M-right> :call MoveCurrentTab(1)<Esc>

--

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
(Continue reading)

sheetal | 17 Aug 2012 08:51
Picon

Re: moving tab pages using maps

Hello Ping and JohnBeckett,

Ping, Your solution is totally working. Thanks for this.
and JohnBeckett, You are right about this,

Marcin Szamotulski wrote: 
> It is possible and quite easy: 
> 
> map <A-S-j> :tabm +1<CR> 
> map <A-S-k> :tabm -1<CR> 

This doesn't work.

--

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

Marcin Szamotulski | 17 Aug 2012 14:34
Picon
Gravatar

Re: moving tab pages using maps

On 23:51 Thu 16 Aug     , sheetal wrote:
> Hello Ping and JohnBeckett,
> 
> Ping, Your solution is totally working. Thanks for this.
> and JohnBeckett, You are right about this,
> 
> Marcin Szamotulski wrote: 
> > It is possible and quite easy: 
> > 
> > map <A-S-j> :tabm +1<CR> 
> > map <A-S-k> :tabm -1<CR> 
You are right this doesn't work, but only because of the lhs.

Best,
Marcin
> 
> This doesn't work.
> 
> -- 
> 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

--

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


Gmane