Mailing List Archive

Vim - Buffers
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
Re: Vim - Buffers [ In reply to ]
On Tue, Sep 28, 2004 at 06:47:49AM +0200, Thilo Six wrote:
> 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.
>
> [snip]
>
> nmap <silent> <M-1> :call <SID>SelectBuffer( 1)<CR>
> nmap <silent> <M-2> :call <SID>SelectBuffer( 2)<CR>
>
> [snip]
>
> ===========================================
>
> 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.

Sounds like maybe your xterm is setup generate an escape sequence
when you use the Alt key. Try making sure that "Meta Sends
Escape" is NOT selected in your Xterm popup menus, and add the
following line to /etc/X11/app-defaults/XTerm:

*eightBitInput: true

- richard

--
Richard Kilgore
rkilgore@hotpop.com

--
gentoo-user@gentoo.org mailing list
Re: Vim - Buffers [ In reply to ]
Richard Kilgore wrote, On 28.09.2004 07:20:
> On Tue, Sep 28, 2004 at 06:47:49AM +0200, Thilo Six wrote:

> Sounds like maybe your xterm is setup generate an escape sequence
> when you use the Alt key. Try making sure that "Meta Sends
> Escape" is NOT selected in your Xterm popup menus, and add the
> following line to /etc/X11/app-defaults/XTerm:
>
> *eightBitInput: true
>
> - richard

Thank you very much. That´s it.

I put

*eightBitInput: true
*metaSendsEscape: false

in ~/.Xdefaults and now it´s working.

great ;)


Bye Thilo


--
gentoo-user@gentoo.org mailing list
Re: Vim - Buffers [ In reply to ]
Thilo Six wrote, On 28.09.2004 08:22:

>
> Thank you very much. That´s it.
>
> I put
>
> *eightBitInput: true
> *metaSendsEscape: false
>
> in ~/.Xdefaults and now it´s working.
>
> great ;)
>
>
> Bye Thilo

This doesn´t work in KDE Konsole. In Konsole ALT sill seems not
to work. There are no shortcuts for ALT+. oder ALT+, in KDE.

Has someone an idea what could cause this?

bye Thilo


--
gentoo-user@gentoo.org mailing list
Re: Re: Vim - Buffers [ In reply to ]
On Tue, 28 Sep 2004 15:32:50 +0200 Thilo Six <T.Six@gmx.de> wrote:
| This doesn´t work in KDE Konsole. In Konsole ALT sill seems not
| to work. There are no shortcuts for ALT+. oder ALT+, in KDE.
|
| Has someone an idea what could cause this?

Yeah, Konsole is totally broken when it comes to terminfo. Try using a
different terminal emulator.

--
Ciaran McCreesh : Gentoo Developer (Sparc, MIPS, Vim, Fluxbox)
Mail : ciaranm at gentoo.org
Web : http://dev.gentoo.org/~ciaranm
Re: Vim - Buffers [ In reply to ]
Ciaran McCreesh wrote, On 28.09.2004 16:25:
> On Tue, 28 Sep 2004 15:32:50 +0200 Thilo Six <T.Six@gmx.de> wrote:
> | This doesn´t work in KDE Konsole. In Konsole ALT sill seems not
> | to work. There are no shortcuts for ALT+. oder ALT+, in KDE.
> |
> | Has someone an idea what could cause this?
>
> Yeah, Konsole is totally broken when it comes to terminfo. Try using a
> different terminal emulator.
>

Hi

as I said befor already, thanks Ciaran McCreesh for the cool stuff ;))

hmm... this with konsole is sad. I use it cause it has tabbing features.
This safes a lot space on screen and is much easier to handle
several open sessions.

I know from a Xfce 4.2 LiveCD that in there is a replacement for that
more based upon Xterm. That would be a great solution.
This isn´t available now, isn´t it?

(Speaking up Terms. Maybe someone will have a look on "my" homepage:
http://forums.gentoo.org/viewtopic.php?t=218156)


I have some other questions now, too.

I know the bash is EMACS like and I know you can switch it to Vim behavior.
What and where do I have to change to accomplish this?

It´s also possible to change the standard system pager to Vim.
What advantages does this have?
Is it just to have it uniform? As on my system Vim loads slower than
less. Is it worth to change?


I noticed a difference in speed when cycling through the files.
When I use:
nnoremap <A-.> :confirm bn<CR>
nnoremap <A-,> :confirm bp<CR>

it´s fast, just a keystroke.

When I use:
nmap <silent> <S-Left> :bprev<CR>
nmap <silent> <S-Right> :bnext<CR>

there is a delay from about one second.
What is the difference between them?


Thanks you all out there. Making it such fun using Gentoo. ;)

bye Thilo


--
gentoo-user@gentoo.org mailing list
Re: Re: Vim - Buffers [ In reply to ]
On Tue 28.09 21:41, Thilo Six wrote:
> Ciaran McCreesh wrote, On 28.09.2004 16:25:
> >Yeah, Konsole is totally broken when it comes to terminfo. Try using
> >a different terminal emulator.
>
> hmm... this with konsole is sad. I use it cause it has tabbing
> features. This safes a lot space on screen and is much easier to
> handle several open sessions.

You could use multi-aterm (probably like konsole, which I don't know
really) or screen (which I do know and which can do a lot more than just
have opened more than one session in a terminal).

Bert

--
gentoo-user@gentoo.org mailing list
Re: Re: Vim - Buffers [ In reply to ]
Am Dienstag, 28. September 2004 21:41 schrieb Thilo Six:
> It´s also possible to change the standard system pager to Vim.
> What advantages does this have?
> Is it just to have it uniform? As on my system Vim loads slower than
> less. Is it worth to change?

I don't think, it's worth to change, as pressing 'v' in "less" opens your
default editor (set in /etc/rc.conf).

> bye Thilo

Hand,
Michael

--
gentoo-user@gentoo.org mailing list
Re: Re: Vim - Buffers [ In reply to ]
On Wednesday 29 September 2004 03:41, Thilo Six wrote:

> I know the bash is EMACS like and I know you can switch it to Vim behavior.
> What and where do I have to change to accomplish this?

set -o vim
set -o emacs

in your bashrc or whatever.

OR

set editing-mode vi

in .inputrc

--
Jason Wong

--
gentoo-user@gentoo.org mailing list
Re: Vim - Buffers [ In reply to ]
Jason Wong wrote, On 29.09.2004 00:18:
> On Wednesday 29 September 2004 03:41, Thilo Six wrote:
>
>
>>I know the bash is EMACS like and I know you can switch it to Vim behavior.
>>What and where do I have to change to accomplish this?
>
>
> set -o vim
> set -o emacs

I don´t have to set them both, do I?


> in your bashrc or whatever.

When I put => set -o vim

in ~/.bashrc I get an error:

-bash: set: vim: invalid option name


> set editing-mode vi
>
> in .inputrc

I put this in /etc/iputrc.


bye Thilo


--
gentoo-user@gentoo.org mailing list
Re: Vim - Buffers [ In reply to ]
Michael Schreckenbauer wrote, On 28.09.2004 23:48:
> Am Dienstag, 28. September 2004 21:41 schrieb Thilo Six:
>
>>It´s also possible to change the standard system pager to Vim.
>>What advantages does this have?
>>Is it just to have it uniform? As on my system Vim loads slower than
>>less. Is it worth to change?
>
>
> I don't think, it's worth to change, as pressing 'v' in "less" opens your
> default editor (set in /etc/rc.conf).

Thanks for the reminder. I changed rc.conf.
Yes I agree it´s not worth to switch from less.


> Hand,
schüttel ;)

> Michael


Bye Thilo


--
gentoo-user@gentoo.org mailing list
Re: Re: Vim - Buffers [ In reply to ]
On Wednesday 29 September 2004 08:29, Thilo Six wrote:

> > set -o vim
> > set -o emacs
>
> I don´t have to set them both, do I?

Just one or the other (they toggle each other)

> > in your bashrc or whatever.
>
> When I put => set -o vim
>
> in ~/.bashrc I get an error:
>
> -bash: set: vim: invalid option name

Sorry, that should be:

set -o vi

--
Jason Wong

--
gentoo-user@gentoo.org mailing list
Re: Vim - Buffers [ In reply to ]
Bert Buchholz wrote, On 28.09.2004 23:33:

> You could use multi-aterm (probably like konsole, which I don't know
> really) or screen (which I do know and which can do a lot more than just
> have opened more than one session in a terminal).
>
> Bert

hmmm no I probably won´t use multi-aterm.
I tried it once and it were not what I expected.

I will give multi-gnome-terminal a try instead.


Thanks for your reply

bye Thilo


--
gentoo-user@gentoo.org mailing list
Re: Re: Vim - Buffers [ In reply to ]
Thilo Six wrote:
> Bert Buchholz wrote, On 28.09.2004 23:33:
>
>> You could use multi-aterm (probably like konsole, which I don't know
>> really) or screen (which I do know and which can do a lot more than just
>> have opened more than one session in a terminal).
>>
>> Bert
>
>
> hmmm no I probably won´t use multi-aterm.
> I tried it once and it were not what I expected.
>
> I will give multi-gnome-terminal a try instead.
>
>
> Thanks for your reply
>
> bye Thilo
>
>

I'm using multi-gnome-terminal myself; it's actually quite nice. Now
that I've figured out how to copy and paste the term output
(gnome-terminal lets you right-click and select from a menu, or use
Shift-Ctrl-C for copy and Shift-Ctrl-V for paste, but multi-gnome
terminal uses select and left-click to copy and middle click to paste
that buffer into any app, so you actually have two copy buffers running;
the X one and the MGT one, which is just great) I'm liking it a whole
lot better. It saves my term tabs between sessions via a setting inside
the program, so when I start it at startup I have my 3 most-used terms
already available, and you can open a new term tab in a variety of ways.

It's pretty cool, overall, once you get used to how it's different from
konsole and normal gnome-terminal. Maybe one day it'll be GTK2 and also
look a bit better (but it's a term, who really cares).

Holly

--
gentoo-user@gentoo.org mailing list
Re: Vim - Buffers [ In reply to ]
Jason Wong wrote, On 29.09.2004 02:48:

>>When I put => set -o vim
>>
>>in ~/.bashrc I get an error:
>>
>>-bash: set: vim: invalid option name
>
>
> Sorry, that should be:
>
> set -o vi

Thanks that seems to work.
"Seems" means now I have to check where the differences
between those modes are.

Thanks

bye Thilo


--
gentoo-user@gentoo.org mailing list
Re: Re: Vim - Buffers [ In reply to ]
On Tue, Sep 28, 2004 at 09:41:22PM +0200, Thilo Six wrote:
> Ciaran McCreesh wrote, On 28.09.2004 16:25:
> >On Tue, 28 Sep 2004 15:32:50 +0200 Thilo Six <T.Six@gmx.de> wrote:
> >| This doesn?t work in KDE Konsole. In Konsole ALT sill seems not
> >| to work. There are no shortcuts for ALT+. oder ALT+, in KDE.
> >
> > [snip]
> >
> >Yeah, Konsole is totally broken when it comes to terminfo. Try using a
> >different terminal emulator.
>
> [snip]
>
> hmm... this with konsole is sad. I use it cause it has tabbing features.
> This safes a lot space on screen and is much easier to handle
> several open sessions.
>
> I know from a Xfce 4.2 LiveCD that in there is a replacement for that
> more based upon Xterm. That would be a great solution.
> This isn?t available now, isn?t it?

emerge app-misc/screen

and you'll never go back! It works inside xterm, on the console,
inside an ssh login. It opens multiple terminal sessions in
one window, like the tabs in konsole and provides switching
between them using various key combos, including user-defined
ones (I have Alt-l defined to switch to the "next" one, and I
cycle through one at a time that way).

It supports disconnecting and reconnecting later from a different
xterm window, console, or ssh session. You can perform a
backwards search through all the screens of data you have seen
during the current session, copy and paste data out to a file or
just to the copy buffer. I have resurrected a few text files
that I accidentally deleted or overwrote with an old version
using this feature. Also good when you have a command in your
history but want to run it in the _other_ window - copy it out
and paste it in the other shell session.

I also have key combos defined to open up various things in new
sessions, like a root window (su -), ssh logins to hosts I
commonly use, w3m, etc. And I can specify that new zsh sessions
start as window number 0, 1, 2, ..., root window sessions start
at 4, remote sessions to the host I use 2nd most often start at
8, and all others start at 12, so I always know where everything
is when cycling through them.

And who knows what else I haven't found!

- richard

--
Richard Kilgore
rkilgore@hotpop.com

--
gentoo-user@gentoo.org mailing list
Re: Vim - Buffers [ In reply to ]
Richard Kilgore wrote, On 29.09.2004 04:21:

> emerge app-misc/screen
I have it already installed. Nerver used it though.

[snip screen features]


> And who knows what else I haven't found!
>
> - richard

Do you know a practice tutorial about all this screen features
and have a good pointer for me?

I would like to have closer look at screen after your explanation.

This one I know already, but it´s not so much.
http://www.gentoo.org/news/en/gwn/20030714-newsletter.xml#doc_chap9


Thank you for your advice.

bye Thilo


--
gentoo-user@gentoo.org mailing list
Re: Re: Vim - Buffers [ In reply to ]
On Tue, 2004-09-28 at 22:12, Thilo Six wrote:
> Richard Kilgore wrote, On 29.09.2004 04:21:
>
> > emerge app-misc/screen
> I have it already installed. Nerver used it though.
> Do you know a practice tutorial about all this screen features
> and have a good pointer for me?
>
> I would like to have closer look at screen after your explanation.

Try this one to start...
http://www.kuro5hin.org/story/2004/3/9/16838/14935
--
Owen Ford <oford@arghblech.com>

() ascii ribbon campaign - against html e-mail
/\ - against proprietary attachments
Re: Re: Vim - Buffers [ In reply to ]
On Wed, Sep 29, 2004 at 05:12:35AM +0200, Thilo Six wrote:
> Richard Kilgore wrote, On 29.09.2004 04:21:
>
> >emerge app-misc/screen
> I have it already installed. Nerver used it though.
>
> [snip screen features]
>
> >And who knows what else I haven't found!
> >
> > - richard
>
> Do you know a practice tutorial about all this screen features
> and have a good pointer for me?
>
> I would like to have closer look at screen after your explanation.
>
> This one I know already, but it?s not so much.
> http://www.gentoo.org/news/en/gwn/20030714-newsletter.xml#doc_chap9

Don't remember where I started with it. Here are a couple intros
I have seen recently:

http://www.linuxjournal.com/article.php?sid=6340
http://www.linux-mag.com/2003-06/power_01.html

Neither talks about adding key bindings, though, which makes all
the difference for me. To bind actions to your own key bindings,
read the screen man page and look for the CUSTOMIZATION section:
especially the parts about the bind and bindkey commands. To
change the command character (ctrl-A) to something else, use the
"escape" command in your .screenrc.

- richard

--
Richard Kilgore
rkilgore@hotpop.com

--
gentoo-user@gentoo.org mailing list
Re: Re: Vim - Buffers [ In reply to ]
On Wed 29.09 05:12, Thilo Six wrote:
> Richard Kilgore wrote, On 29.09.2004 04:21:
>
> >emerge app-misc/screen
> I have it already installed. Nerver used it though.
>
> [snip screen features]
>
> >And who knows what else I haven't found!
>
> Do you know a practice tutorial about all this screen features
> and have a good pointer for me?

I got one advice to make screen a bit easier: Use the hardstatus line.
It's a line that's constantly at the bottom of your terminal. showing
some information, that you can define, for example like this:

http://userpage.fu-berlin.de/~buchholz/screen.jpg

You see I have currently three shells in one terminal and I switch
between them with F7 (prev) and F8 (next). This statusline is done like
this in your .screenrc:

hardstatus alwayslastline "%{=b wk}..:: %D %d-%m %c %1` %2`° | %-w%{=br}%n %t%{-}%+w ::.."

The %1` and %2` are replaced by some mailchecker I made up and the CPU
temperatur. ;)

Cycling through your terminals with F7 and F8 is as easy as this:

bindkey -k k7 prev
bindkey -k k8 next

And thousands of other great features ...

Bert

--
gentoo-user@gentoo.org mailing list
Re: Vim - Buffers [ In reply to ]
Bert Buchholz wrote, On 29.09.2004 14:34:

> I got one advice to make screen a bit easier: Use the hardstatus line.
> It's a line that's constantly at the bottom of your terminal. showing
> some information, that you can define, for example like this:
>
> http://userpage.fu-berlin.de/~buchholz/screen.jpg
>
> You see I have currently three shells in one terminal and I switch
> between them with F7 (prev) and F8 (next). This statusline is done like
> this in your .screenrc:
>
> hardstatus alwayslastline "%{=b wk}..:: %D %d-%m %c %1` %2`° | %-w%{=br}%n %t%{-}%+w ::.."
>
> The %1` and %2` are replaced by some mailchecker I made up and the CPU
> temperatur. ;)
>
> Cycling through your terminals with F7 and F8 is as easy as this:
>
> bindkey -k k7 prev
> bindkey -k k8 next
>
> And thousands of other great features ...
>
> Bert

Now this is realy good tip. Thanks.
I was wondering about just right this, if something like this were
possible.
Thank you. Saved me much time to look for my own solution. ;)

bye Thilo


--
gentoo-user@gentoo.org mailing list
Re: Vim - Buffers [ In reply to ]
Bert Buchholz wrote, On 29.09.2004 14:34:

> You see I have currently three shells in one terminal and I switch
> between them with F7 (prev) and F8 (next). This statusline is done like
> this in your .screenrc:
>
> hardstatus alwayslastline "%{=b wk}..:: %D %d-%m %c %1` %2`° | %-w%{=br}%n %t%{-}%+w ::.."
>
> The %1` and %2` are replaced by some mailchecker I made up and the CPU
> temperatur. ;)
>
> Cycling through your terminals with F7 and F8 is as easy as this:
>
> bindkey -k k7 prev
> bindkey -k k8 next
>
> And thousands of other great features ...
>
> Bert

Thank very much Richard Kilgore and Bert Buchholz.
This trick with screen und this cool statusline is just want I wanted.

Now I can use Vim as I would like to.

Do have any other hints and tricks like that?

bye Thilo

PS. any other hint and trick is always very welcome ;)


--
gentoo-user@gentoo.org mailing list
Re: Vim - Buffers [ In reply to ]
Thilo Six wrote, On 29.09.2004 02:50:
> Bert Buchholz wrote, On 28.09.2004 23:33:
>
>
>>You could use multi-aterm (probably like konsole, which I don't know
>>really) or screen (which I do know and which can do a lot more than just
>>have opened more than one session in a terminal).
>>
>>Bert
>
>
> hmmm no I probably won´t use multi-aterm.
> I tried it once and it were not what I expected.
>
> I will give multi-gnome-terminal a try instead.
>
>
> Thanks for your reply
>
> bye Thilo

Now I´ve tried multi-gnome-terminal and also even gnome-terminal.
Both do not work for me.

ALT+. and ALT+, do not work in none of them.
It´s like the same problem I had with Konsole.

But I found a solution to get it to work - with screen.
Just read a bit below in the thread, if your interrested in how.

bye Thilo


--
gentoo-user@gentoo.org mailing list
Re: Vim - Buffers [ In reply to ]
Thilo Six wrote, On 28.09.2004 21:41:

> I know from a Xfce 4.2 LiveCD that in there is a replacement for that
> more based upon Xterm. That would be a great solution.
> This isn´t available now, isn´t it?

I had a closer look on that LiveCD again and this "new" Term ist "just"
a plain gnome-terminal.

FYI Thilo


--
gentoo-user@gentoo.org mailing list
Re: Vim - Buffers [ In reply to ]
Richard Kilgore wrote, On 29.09.2004 04:21:
> emerge app-misc/screen
>
> and you'll never go back!

That´s absolutly true.
>
> And who knows what else I haven't found!
>
> - richard

I just wondering about how to start a screen session just right on Xterm
start. When I put screen& in ~/.bashrc I get:

Must be connected to a terminal.


TIA Thilo


--
gentoo-user@gentoo.org mailing list

1 2  View All