This is a companion discussion topic for the original entry at https://thoughtbot.com/upcase/videos/onramp-to-vim-windows-and-tabs
I was exploring how to move a window from tab1 to tab2 (more general form of
<C-w>T ). One way is:
:lsto note the buffer number of the window I want to move in tab1
:closeto close tab1
gTto tab2 if not already in tab2
:sbuf Nwhere N is the buffer number noted in step 1. This will pop the window into tab2 by doing a horizontal split.
More details in this Stackoverflow Q/A.
In the video it is mentioned that it is possible to configure the status bar to be of a different background color when it is not in focus.
Does anyone know how to achieve it?
Post-Edit: Is there a way to do the opposite of
I mean, grabbing a tab and making it a split.
@fmquaglia I have the following in my .vimrc, it might be wrong, as i am relatively new to vim
hi StatusLine ctermbg=yellow ctermfg=black" bg=dark
hi StatusLineNC cterm=none
Hi @razmig !
Although you’re new you rock, man.
BTW, As I’m new to cterm colors I used this plugin that came handy: http://www.vim.org/scripts/script.php?script_id=3412
Oh! glad i could help.
The plugin looks really nice, although i am a little bit hesitate when it comes to plugins as they grow like monsters and soon things into mess
I hear ya!
It is possible to yank and paste from tab to tab which is really nice.
Is it possible to execute shell commands on new split ?
Hi @karun-code, if I’m understanding you correctly, you’d like to run a shell command whenever you open a new split? You can use
split-window and pass a shell command along with it, e.g.
tmux split-winodw 'vim ~/.tmux-.conf' (this would open your tmux conf file in the split), but once that command completes, the new split window will close.
Alternatively you can set the
set -g default-command 'zsh' command. Typically this defines your startup shell, but in theory you could do more with it.
The last option, and the one I’d likely look into, is to add something to your shell startup file, for example the
~/.zshrc for zsh shells, or
~/.bashrc for bash. You can run a command from it, and you could even make it conditional on being in tmux by checking for the
$TMUX environment variable:
[[ ! -z "$TMUX" ]] && echo 'in tmux' || true
That checks for being in tmux, and then does
echo 'in tmux' if so, or exits quietly (the
|| true bit). You can replace
echo 'in tmux' with your preferred shell script.
Hi @christoomey, Thanks for your response and sharing your knowledge through this wonderful trail - Onramp to Vim, it has been very interesting going through it, and opens up new possibilities.
My earlier query was related to opening a new split in native vim (without using tmux) and run shell commands there, so as to test the code being written in the original split.
As I understand that may not be the correct use-case for vim and the very reason for having tmux.