You are not logged in.

#1 2007-05-02 00:52:19

KomodoDave
Member
From: Oxford, UK
Registered: 2007-04-22
Posts: 162
Website

Vim Ctrl + Tab for Tabs navigation

:noremap <silent> <c-Tab> :tabn<CR>
noremap! <silent> <C-Tab> :tabn<CR>

This doesn't work for me - any idea why? Ctrl-tab just doesn't shift tabs... I've definitely not bound the combination elsewhere in my .vimrc either.

- KD

Last edited by KomodoDave (2007-05-02 02:38:33)

Offline

#2 2007-05-02 18:59:22

mosor
Member
Registered: 2007-04-02
Posts: 22

Re: Vim Ctrl + Tab for Tabs navigation

Here are my tab related settings (that work):

set showtabline=2               " File tabs allways visible
:nmap <C-S-tab> :tabprevious<cr>
:nmap <C-tab> :tabnext<cr>
:nmap <C-t> :tabnew<cr>
:map <C-t> :tabnew<cr>
:map <C-S-tab> :tabprevious<cr>
:map <C-tab> :tabnext<cr>
:map <C-w> :tabclose<cr>
:imap <C-S-tab> <ESC>:tabprevious<cr>i
:imap <C-tab> <ESC>:tabnext<cr>i
:imap <C-t> <ESC>:tabnew<cr>

Offline

#3 2007-05-02 21:53:16

KomodoDave
Member
From: Oxford, UK
Registered: 2007-04-22
Posts: 162
Website

Re: Vim Ctrl + Tab for Tabs navigation

mosor wrote:

Here are my tab related settings (that work):

set showtabline=2               " File tabs allways visible
:nmap <C-S-tab> :tabprevious<cr>
:nmap <C-tab> :tabnext<cr>
:nmap <C-t> :tabnew<cr>
:map <C-t> :tabnew<cr>
:map <C-S-tab> :tabprevious<cr>
:map <C-tab> :tabnext<cr>
:map <C-w> :tabclose<cr>
:imap <C-S-tab> <ESC>:tabprevious<cr>i
:imap <C-tab> <ESC>:tabnext<cr>i
:imap <C-t> <ESC>:tabnew<cr>

Thanks for posting, mosor! Sadly your command lines don't work for me either...

Here's my .vimrc, much of which was cloned from phrakture's :

"""""""""" general options """"""""""

set nocompatible                " Use Vim settings, rather then Vi settings (much better!).
                                " This must be first, because it changes other options as a side effect.
"syntax enable                  " enable syntax highlighting and keep current colour settings
syntax on                       " enable syntax highlighting and override current colour settings
behave xterm                    " mouse and selection xterm behaviour
filetype plugin indent on       " filetype dependent indenting and plugins
set autoindent                  " indents line relative to the line above it
set autowrite                   " automatically write contents of file where sensible
set backspace=indent,eol,start  " allow backspacing over eevrything in insert mode
set backup backupdir=$HOME/.vim/backup " set backup directory
set cinoptions=g0,:0,l1,(0,t0   " C indentation options
set clipboard=unnamed           " yank and paste in visual mode without prepending "*
set cmdheight=1                 " cmdline height
set complete=.,t,i,b,w,k        " keyword completion configuration
set encoding=utf-8              " encoding
set expandtab                   " insert spaces instead of tab character
set formatoptions+=l            " add format option preventing lines longer than 'textwidth' being broken
set guioptions-=T               " no toolbar
set hidden                      " don't have to save when switching buffers
set history=100                 " cmdline history table size
"set ignorecase                 " search is case insensitive when search term is all lower case
set incsearch                   " live search while typing search expression
set laststatus=2                " always display the status line
set nohlsearch                  " no highlighting when performing search
set nowrap                      " don't wrap visible lines
set number                      " precede line with line number when printing
set pastetoggle=<F9>            " toggle paste mode
set previewheight=5             " preview window size
"set ruler                       " show line and column in status line
set shell=/bin/sh               " set the shell to be used
set shiftwidth=4                " number of spaces used for (auto)indent
set showcmd                     " show partial command in status line
set showmode                    " show whether in insert, visual mode etc
set showmatch                   " indicate matching parentheses, braces etc
set showtabline=2               " File tabs allways visible
set shortmess=a                 " abbreviate file messages
set smartcase
set smartindent
set softtabstop=4               " tab defaults to 4 spaces while performing editing operations
set splitbelow                  " split creates new window below current one
set statusline=%-3.3n\ %f\ %r%#Error#%m%#Statusline#\ (%l/%L,\ %c)\ %P%=%h%w\ %y\ [%{&encoding}:%{&fileformat}]\ \  "status line settings
set tabstop=4                   " tab defaults to 4 spaces
set textwidth=80                " maximum column width of inserted text - longer lines are broken after whitespace
set ttyfast                     " for fast terminals - smoother (apparently)
set termencoding=utf-8
set whichwrap=h,l,<,>,[,]       " allow line-wrapped navigation
set wildchar=<Tab>              " type tab in cmdline to start wildcard expansion
set wildmenu                    " enhanced cmdline completion
set wildmode=longest:full,full  " cmdline completion mode settings
set writebackup                 " make a file backup before overwriting it

" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
         \ | wincmd p | diffthis

"""""""""" keyboard mappings """"""""""

" Dvorak caret navigation

:noremap t <Up>
:noremap h <Down>
:noremap d <Left>
:noremap n <Right>
:noremap k d
:noremap l n
:noremap j t 

" Window split and navigation
:noremap <C-w><S-s> :vsplit<CR>
:noremap <C-w>t <C-w><Up>
:noremap <C-w>h <C-w><Down>
:noremap <C-w>d <C-w><Left>
:noremap <C-w>n <C-w><Right>

" Ctrl-s saves
:inoremap <C-s> <Esc>:w<CR>a
:nnoremap <C-s> :w<CR>

" Tab manipulation
":noremap <silent> <C-t> :tabnew<cr>
":noremap <silent> <C-x> :tabc<cr>
":noremap <silent> <C-tab> :tabn<cr>
":noremap <silent> <C-s-tab> :tabp<cr> 
"noremap! <silent> <C-t> :tabnew<cr>
"noremap! <silent> <C-x> :tabc<cr>
"noremap! <silent> <C-tab> :tabn<cr>
"noremap! <silent> <C-s-tab> :tabp<cr> 

:nmap <C-S-tab> :tabprevious<cr>
:nmap <C-tab> :tabnext<cr>
:nmap <C-t> :tabnew<cr>
:map <C-t> :tabnew<cr>
:map <C-S-tab> :tabprevious<cr>
:map <C-tab> :tabnext<cr>
:map <C-x> :tabclose<cr>
:imap <C-S-tab> <ESC>:tabprevious<cr>i
:imap <C-tab> <ESC>:tabnext<cr>i
:imap <C-t> <ESC>:tabnew<cr>

"Key bindings
noremap <silent> <F1> :Tlist<cr>
noremap <silent> <F2> :VSBufExplore<cr>
"noremap <silent> <F3> :Make<cr>
noremap <silent> <F3> <c-o>:Project<cr>
noremap <silent> <F6> :set spell!<cr>

noremap! <silent> <F1> <c-o>:Tlist<cr>
noremap! <silent> <F2> <c-o>:VSBufExplore<cr>
"noremap! <silent> <F3> <c-o>:Make<cr>
noremap! <silent> <F3> <c-o>:Project<cr>
noremap! <silent> <F6> <c-o>:set spell!<cr>

" I never use these anyway
noremap ( :bprev<cr>
noremap ) :bnext<cr>
":inoremap ^] ^[A
":inoremap ð ^N 
" Don't use Ex mode, use Q for formatting
"map Q gq

"""""""""" autocommand stuff """"""""""

" Only do this part when compiled with support for autocommands.
if has("autocmd")

  " Enable file type detection.
  " Use the default filetype settings, so that mail gets 'tw' set to 72,
  " 'cindent' is on in C files, etc.
  " Also load indent files, to automatically do language-dependent indenting.
  filetype plugin indent on

  " Put these in an autocmd group, so that we can delete them easily.
  augroup vimrcEx
  au!

  " For all text files set 'textwidth' to 78 characters.
  autocmd FileType text setlocal textwidth=78

  " When editing a file, always jump to the last known cursor position.
  " Don't do it when the position is invalid or when inside an event handler
  " (happens when dropping a file on gvim).
  autocmd BufReadPost *
    \ if line("'\"") > 0 && line("'\"") <= line("$") |
    \   exe "normal! g`\"" |
    \ endif

  augroup END

else

  set autoindent        " always set autoindenting on

endif " has("autocmd")

" if autocmd is on
if has("autocmd")
    " read Ex commands from file if syntax matches
    au Syntax {cpp,c,idl} runtime syntax/doxygen.vim
    au Syntax {cpp,c,lisp,scheme} runtime plugin/RainbowParenthesis.vim

    au FileType qf if &buftype == "quickfix" |
                   \    setlocal statusline=%-3.3n\ %0*[quickfix]%=%2*\ %<%P |
                   \endif
    au FileType mail setlocal spell
    au FileType cvs setlocal spell
    au FileType help setlocal statusline=%-3.3n\ [help]%=\ %<%P
    " for all files enable cursorline upon entering a window, and disable when
    " leaving
    "au WinEnter * setlocal cursorline 
    "au WinLeave * setlocal nocursorline 
    " ???
    au BufReadPost * if line("'\"")>0 && line("'\"")<=line("$")|exe "normal g`\""|endif
    " syntax highlighting for html that permits embedded javascript
    au BufRead *.html set filetype=htmlm4
    " when a PKGBUILD is loaded into a buffer,  trigger all sh filetype autocommands
    " this occurs before modelines are read
    au BufRead,BufNewFile PKGBUILD set ft=sh
    " when a .as file is loaded into a buffer,, trigger all actionscript
    " filetype autocommands, and use C indenting rules
    " this occurs before modelines are read
    au BufRead,BufNewFile *.as setlocal ft=actionscript cindent

    " omni functionality
    au FileType css setlocal ofu=csscomplete#CompleteCSS
    au Filetype * if exists('&ofu') && &ofu == "" |
                       \    set ofu=syntaxcomplete#Complete |
                       \endif
endif
"""""""""" abbreviations and remaps """"""""""

":abbreviate #! #!/usr/bin/env python

"""""""""" other stuff """"""""""

" vim.org tip 867: get help on python in vim, eg :Pyhelp os
:command -nargs=+ Pyhelp :call ShowPydoc("<args>")
function ShowPydoc(module, ...)
    let fPath = "/tmp/pyHelp_" . a:module . ".pydoc"
    :execute ":!pydoc " . a:module . " > " . fPath
    :execute ":sp ".fPath
endfunction

"bracket autocompletion
inoremap ( ()<ESC>i
inoremap [ []<ESC>i
inoremap { {<CR>}<ESC>O
autocmd Syntax html,vim inoremap < <lt>><ESC>i| inoremap > <c-r>=ClosePair('>')<CR>
inoremap ) <c-r>=ClosePair(')')<CR>
inoremap ] <c-r>=ClosePair(']')<CR>
inoremap } <c-r>=CloseBracket()<CR>
inoremap " <c-r>=QuoteDelim('"')<CR>
inoremap ' <c-r>=QuoteDelim("'")<CR>

function ClosePair(char)
  if getline('.')[col('.') - 1] == a:char
    return "\<Right>"
  else
    return a:char
  endif
endf

function CloseBracket()
  if match(getline(line('.') + 1), '\s*}') < 0
    return "\<CR>}"
  else
    return "\<ESC>j0f}a"
  endif
endf

function QuoteDelim(char)
  let line = getline('.')
  let col = col('.')
  if line[col - 2] == "\\"
    "Inserting a quoted quotation mark into the string
    return a:char
  elseif line[col - 1] == a:char
    "Escaping out of the string
    return "\<Right>"
  else
    "Starting a string
    return a:char.a:char."\<ESC>i"
  endif
endf

"folding options
if has("folding")
    " enable folds
    set foldenable
    " {{{ markers indicate folds
    set foldmethod=marker
    " leave all/most folds open
    set foldlevel=100
endif

" if using gvim
if has('gui_running')
    " allow pasting into other applications after visual selection
    set guioptions+=a
    " use console dialogs instead of popups
    set guioptions+=c
    " don't add tab pages
    set guioptions-=e
    " don't include toolbar
    set guioptions-=T
    " set color scheme
    colors zenburn
    " if running under windows
    if has('win32') 
        " set number of columns and lines
        set columns=120
        set lines=60
        " select font
        set guifont=Bitstream_Vera_Sans_Mono:h8:cANSI
    else
        " select font
        set guifont=Bitstream\ Vera\ Sans\ Mono\ 8
    endif
" if we're in a linux console
elseif (&term == 'screen.linux') || (&term =~ '^linux')
    " use 8 bit colour
    set t_Co=8
    " set color scheme
    colors desert
" if we're in xterm, urxvt or screen with 256 colours
elseif (&term == 'rxvt-unicode') || (&term =~ '^xterm') || (&term =~ '^screen-256')
    " allow mouse in all editing modes
    set mouse=a
    " use xterm mouse behaviour
    set ttymouse=xterm
    " set encoding to uft-8
    set termencoding=utf-8
    " set color scheme
    colors desert256-transparent
" if we're in a different terminal
else
    " set color scheme
    colors desert
endif

" if we're in screen and autocmd is enabled
if &term =~ "^screen" && has("autocmd")
    " this fixes background artifacting when leaving vim inside screen
    autocmd VimLeave * :set term=screen
endif

let mapleader = "`"
" cd includes current directory, as well as $HOME and projects folders
let &cdpath=','.expand("$HOME").','.expand("$HOME").'/projects'

" if vim version is >= 7
if v:version >= 700
    " display cursor line
    set cursorline
    " Insert mode completion options
    set completeopt=menu,menuone,longest,preview
    " spellchecker language is US
    set spelllang=en_us
    " spelling suggestions operate on 'fast' mode with max 20 suggestions
    set spellsuggest=fast,20
    " use min 1 column for line number
    set numberwidth=1
    " imma commnt with missspellings, use me tu tesst
endif


"set dictionary=/usr/share/dict/words

" typing q: == :q
nmap q: :q<cr>
" typing :Q == :q
nmap :Q :q<cr>

" man-page autoreturn after view
nmap K K<cr>

iab NDB Author: N David Brown

"tags files search for a project
"   :FindTags('~/projects/something')
"command! -nargs=1 -complete=dir FindTags :call ProjectTags(<args>)
"function! ProjectTags(projectbase)
    "let tfiles = glob("$(find ".a:projectbase." -name tags -print)")
    "let &tags = substitute(tfiles, "\n", ",", "g")
"endfunction

"command! -nargs=* Make :call SilentMake(<f-args>)
"function! SilentMake()
    "let oldsp=&shellpipe
    "setlocal shellpipe=>%s\ 2>&1
    "exe 'silent make '.string(a:000)
    "cwindow
    "set shellpipe=&oldsp
    "redraw! "this screws up the screen sometimes, fix that
"endfunction

"Project
let g:proj_flags = "ibmstg"
let g:proj_window_width = 35

"TODO get this working better
"TagsParser
"let g:TagsParserLastPositionJump = 1
"let g:TagsParserCurrentFileCWD = 1
let g:TagsParserWindowSize = 30
"let g:TagsParserAutoOpenClose = 1
"let g:TagsParserSingleClick = 1
"let g:TagsParserHighlightCurrentTag = 1
"let g:TagsParserSortType = "line"
"let g:TagsParserFileReadTag = 1
"let g:TagsParserFileReadDeleteTag = 1

"enable the Vim 7.0 options
if v:version >= 700
  let g:TagsParserCtrlTabUsage = 'tabs'

  "Configure the projects - These have been renamed because the projects I work
  "on at work are not really what is important, but rather the way they are configured.
  let g:TagsParserProjectConfig = {}
  let g:TagsParserProjectConfig['/home/griff/devel/pacman-lib/'] = { 'tagsPath' : '/home/griff/devel/pacman-lib/lib/libalpm/,/home/griff/devel/pacman-lib/src/pacman/' }
endif

"TagList
"let Tlist_Display_Tag_Scope = 1 "ugh...
let g:Tlist_Display_Prototype = 1
let g:Tlist_Use_Right_Window = 1
let g:Tlist_Exit_OnlyWindow = 1
let g:Tlist_Enable_Fold_Column = 0
let g:Tlist_Sort_Type = "name"
let g:Tlist_Compact_Format = 0
let g:Tlist_File_Fold_Auto_Close = 0
let g:Tlist_WinWidth = 50

"VTreeExplorer
let g:treeExplVertical = 1
let g:treeExplWinSize = 35
let g:treeExplDirSort = 1

"NetRW
let g:netrw_keepdir = 1
let g:netrw_winsize = 40
let g:netrw_alto = 1

"BufExplorer
let g:bufExplorerOpenMode=1
let g:bufExplorerSortBy='mru'
let g:bufExplorerSplitType='v'
let g:bufExplorerSplitVertSize = 35
let g:bufExplorerShowDirectories=1

"Valgrind
let g:valgrind_arguments = "--leak-check=yes --num-callers=5000 --time-stamp=yes"
let g:valgrind_use_horizontal_window = 1
let g:valgrind_win_height = 7

"DoxygenToolkit
let g:DoxygenToolkit_authorName = "Aaron Griffin"
let g:DoxygenToolkit_briefTag_funcName = "yes"

"ShowMarks
let g:showmarks_enable = 0
let g:showmarks_ignore_type="hmpqr"

"Buftabs
let g:buftabs_only_basename = 1

"Lisp syntax
"let g:lisp_rainbow = 1

- KD

Last edited by KomodoDave (2007-05-04 13:34:16)

Offline

#4 2007-05-02 22:30:41

mosor
Member
Registered: 2007-04-02
Posts: 22

Re: Vim Ctrl + Tab for Tabs navigation

Using your settings on Windows, the tabs work as they should (although, they're not GUI tabs). So I guess the problem is somewhere else...

Last edited by mosor (2007-05-02 22:31:00)

Offline

#5 2007-05-02 22:32:51

KomodoDave
Member
From: Oxford, UK
Registered: 2007-04-22
Posts: 162
Website

Re: Vim Ctrl + Tab for Tabs navigation

mosor wrote:

Using your settings on Windows, the tabs work as they should (although, they're not GUI tabs). So I guess the problem is somewhere else...

Ok, thanks for that info mosor smile

- KD

Offline

#6 2007-05-02 23:42:07

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Vim Ctrl + Tab for Tabs navigation

I'm pretty sure this is a terminal issue.  C-Tab isn't the same thing on a terminal.  In fact, on putty "C-v, C-tab" does nothing at all.

Offline

#7 2007-05-02 23:53:47

KomodoDave
Member
From: Oxford, UK
Registered: 2007-04-22
Posts: 162
Website

Re: Vim Ctrl + Tab for Tabs navigation

phrakture wrote:

I'm pretty sure this is a terminal issue.  C-Tab isn't the same thing on a terminal.  In fact, on putty "C-v, C-tab" does nothing at all.

I guessed it might be, and mosor's response pretty much confirms it. Entering cat mode in urxvt and typing Ctrl+Tab just inserts a tab, so I guess I'll have to google some escape codes to figure out a suitable bind =S

Cheers.

- KD

Offline

#8 2008-04-21 19:15:36

PierreAd
Member
Registered: 2007-05-07
Posts: 19

Re: Vim Ctrl + Tab for Tabs navigation

Yep, I also think it's a terminal problem, it doesn't work here in vim (in gnome term) whereas it works well in gvim !

Offline

Board footer

Powered by FluxBB