Hello
I´ve got following Problem with Vim:
I got used to Nano´s Multibuffer Mode and I would like
to have this in Vim, too.
This means to open several files in one Vim.
I would like to use ALT+. and ALT+, to cycle through the buffers
and then also a shortcut to select a specific buffer.
On Ciaran McCreesh´s homepage I found what I need but
I have a problem with it.
~/.vimrc
===========================================
" Find a buffer with the given number (ordering is such that the first
" entry shown in minibufexpl is 1, the second is 2 and so on). If
" there's already a window open for that buffer, switch to it. Otherwise
" switch the current window to use that buffer.
fun! <SID>SelectBuffer(wantedbufnum)
let l:buflast = bufnr("$")
let l:bufidx = 0
let l:goodbufcount = 0
while (l:bufidx < l:buflast)
let l:bufidx = l:bufidx + 1
if buflisted(l:bufidx)
let l:bufname = bufname(l:bufidx)
if (strlen(l:bufname)) &&
\ getbufvar(l:bufidx, "&modifiable") == 1 &&
\ l:bufname != '-MiniBufExplorer-'
let l:goodbufcount = l:goodbufcount + 1
if l:goodbufcount == a:wantedbufnum
let l:winnr = bufwinnr(l:bufidx)
if l:winnr > -1
execute l:winnr . "wincmd w"
else
execute "buffer " . l:bufidx
endif
break
endif
endif
endif
endwhile
endfun
" Buffer switches
nmap <silent> <M-1> :call <SID>SelectBuffer( 1)<CR>
nmap <silent> <M-2> :call <SID>SelectBuffer( 2)<CR>
nmap <silent> <M-3> :call <SID>SelectBuffer( 3)<CR>
nmap <silent> <M-4> :call <SID>SelectBuffer( 4)<CR>
nmap <silent> <M-5> :call <SID>SelectBuffer( 5)<CR>
nmap <silent> <M-6> :call <SID>SelectBuffer( 6)<CR>
nmap <silent> <M-7> :call <SID>SelectBuffer( 7)<CR>
nmap <silent> <M-8> :call <SID>SelectBuffer( 8)<CR>
nmap <silent> <M-9> :call <SID>SelectBuffer( 9)<CR>
nmap <silent> <M-0> :call <SID>SelectBuffer(10)<CR>
" use ALT+. ALT+, to cycle through files:
nnoremap <A-.> :confirm bn<CR>
nnoremap <A-,> :confirm bp<CR>
"close open files with:
nnoremap <F3> :confirm bd<CR>
nnoremap <F4> :buffers<CR>
===========================================
This works as expected _only_ in Gvim.
I can´t get the Meta key combinations work in Vim.
But Meta key is working in Xterm.
In Vim only this works:
nmap <silent> <C-N> :bnext<CR>
nmap <silent> <C-P> :bprevious<CR>
Has anyone an idea what could be wrong?
Bye Thilo
PS. thanks Ciaran McCreesh for the cool stuff ;))
<http://dict.leo.org/?p=14/p..&search=expected>
--
gentoo-user@gentoo.org mailing list
I´ve got following Problem with Vim:
I got used to Nano´s Multibuffer Mode and I would like
to have this in Vim, too.
This means to open several files in one Vim.
I would like to use ALT+. and ALT+, to cycle through the buffers
and then also a shortcut to select a specific buffer.
On Ciaran McCreesh´s homepage I found what I need but
I have a problem with it.
~/.vimrc
===========================================
" Find a buffer with the given number (ordering is such that the first
" entry shown in minibufexpl is 1, the second is 2 and so on). If
" there's already a window open for that buffer, switch to it. Otherwise
" switch the current window to use that buffer.
fun! <SID>SelectBuffer(wantedbufnum)
let l:buflast = bufnr("$")
let l:bufidx = 0
let l:goodbufcount = 0
while (l:bufidx < l:buflast)
let l:bufidx = l:bufidx + 1
if buflisted(l:bufidx)
let l:bufname = bufname(l:bufidx)
if (strlen(l:bufname)) &&
\ getbufvar(l:bufidx, "&modifiable") == 1 &&
\ l:bufname != '-MiniBufExplorer-'
let l:goodbufcount = l:goodbufcount + 1
if l:goodbufcount == a:wantedbufnum
let l:winnr = bufwinnr(l:bufidx)
if l:winnr > -1
execute l:winnr . "wincmd w"
else
execute "buffer " . l:bufidx
endif
break
endif
endif
endif
endwhile
endfun
" Buffer switches
nmap <silent> <M-1> :call <SID>SelectBuffer( 1)<CR>
nmap <silent> <M-2> :call <SID>SelectBuffer( 2)<CR>
nmap <silent> <M-3> :call <SID>SelectBuffer( 3)<CR>
nmap <silent> <M-4> :call <SID>SelectBuffer( 4)<CR>
nmap <silent> <M-5> :call <SID>SelectBuffer( 5)<CR>
nmap <silent> <M-6> :call <SID>SelectBuffer( 6)<CR>
nmap <silent> <M-7> :call <SID>SelectBuffer( 7)<CR>
nmap <silent> <M-8> :call <SID>SelectBuffer( 8)<CR>
nmap <silent> <M-9> :call <SID>SelectBuffer( 9)<CR>
nmap <silent> <M-0> :call <SID>SelectBuffer(10)<CR>
" use ALT+. ALT+, to cycle through files:
nnoremap <A-.> :confirm bn<CR>
nnoremap <A-,> :confirm bp<CR>
"close open files with:
nnoremap <F3> :confirm bd<CR>
nnoremap <F4> :buffers<CR>
===========================================
This works as expected _only_ in Gvim.
I can´t get the Meta key combinations work in Vim.
But Meta key is working in Xterm.
In Vim only this works:
nmap <silent> <C-N> :bnext<CR>
nmap <silent> <C-P> :bprevious<CR>
Has anyone an idea what could be wrong?
Bye Thilo
PS. thanks Ciaran McCreesh for the cool stuff ;))
<http://dict.leo.org/?p=14/p..&search=expected>
--
gentoo-user@gentoo.org mailing list