Meino Christian Cramer wrote:
:hi
I did the following mappings:
map <F12> <ESC>:tab e ~/.vimrc<CR><C-W>_
map <S-F12> <ESC>:tab e ~/.zshrc<CR><C-W>_
I start vim without any argument and press
F12
. ${HOME}/.vimrc opens but does not create an entry in the tab pages
line at the top of my Vim window -- so far so nice, since it is the
first file loaded and showtabline == 1.
Then I press
Shift-F12
. ${HOME}/.zshrc appears. This is the second file, but still no tab
pages line appears.
Then I do
:tab h :tab
and TADA! the tab pages line apears, showing "~/.zshrc" and
"tabpages.txt"
With
:tabn
I can switch to ${HOME}/.zshrc. Now the tab pages line shows
"~/.zshrc" and "tabpages.txt".
This is at least a little confusing (at least?) to me.
What is the logic of showing/not showing a tab pages line entry ?
Thank you very much in advance for any help !
Keep hacking!
mcc
":tab" only has an effect if the command following it on the same line tries
to open a new window. It is in the same family as ":topleft", ":botright" and
":vertical". If the command doesn't try to open a new window (like your ":e"
command), you won't get a new tab.
IOW, replace ":tab e" by "tab split" in your mappings, and they will open a
new tab. If you want to open a new tab only if the current buffer is not a [No
Name] buffer, it is possible, but more complex, e.g.:
:map <F2> :if (&bufname == '') && !&modified <Bar> e ~/.vimrc <Bar> wincmd _
<Bar> else <Bar> tab split ~/.vimrc <Bar> endif<CR>
(all on one line)
Best regards,
Tony.