Hot answers tagged

29

You are wrong about tmux. Like every terminal-based program — including Vim — it only draws stuff inside cells. This means that Vim and tmux both use the same method to draw vertical borders: they just use a pipe-like character. Tmux uses │ (U+2502) by default while Vim uses | (U+007C). If you want the same separator in Vim, you can simply use the same ...


19

You might try to add the following to your .vimrc. if &term =~ '256color' " disable Background Color Erase (BCE) set t_ut= endif The t_ut option (default = y) describes how vim handles what it wants as background colors compared to attempting to use the current background color. This snippet clears that option. If not, then you might try to set ...


19

There you go : autocmd BufReadPost,FileReadPost,BufNewFile,BufEnter * call system("tmux rename-window 'vim | " . expand("%:t") . "'") Decomposing : autocmd BufReadPost,FileReadPost,BufNewFile,BufEnter * call On buffer read, file read or buffer new file event (see :help autocmd-events) execute the next command : call system() Call a system function ...


11

It seems the problem is that tmux doesn't send your cursor-changing escape codes to the terminal emulator. You need to wrap your desired escape codes in a special sequence that tells tmux that it should pass it on to the outer terminal. The sequence you need to wrap your escape sequence in is \<Esc>Ptmux;\<Esc> ... \<Esc>\\(Source). The ......


9

Ah, I found the culprit by bisecting my .vimrc file. I had mapped Escape in normal mode to clear search highlighting: " Clear highlighting on escape in normal mode nnoremap <esc> :noh<return><esc> However, that will confuse vim as it tries to parse the mouse's escape codes. So what I ended up doing is taking the solution from this answer, ...


8

Well, I solved the problem by myself. as @Carpetsmoker♦ commented, I started to suspect that my .vimrc is a problem. I read this question and started vim with this command inside tmux. vim -u NONE -U NONE -N ~/.vimrc After starting vim with command above, I ran this command inside vim. :syn on :colorscheme solarized8_dark These highlighted my .vimrc ...


7

As of November 2017, all the terminals you are using support the same DECSCUSR escape sequences for changing the cursor shape1. So you don't need to test for the different terminals. As such, the only thing that requires different treatment is tmux, which will only forward escape sequences on to the terminal when surrounded by a DCS sequence. You already ...


7

As far as Vim is concerned, <C-M> and <CR> are the same thing: they are represented in the same way internally. If your terminal is truly sending different keycodes (mine doesn't) for when you press Ctrl-M vs Enter, then you might be able to map them separately by using their literal values when you set up the mappings. Replace the following in ...


5

Even in my own screen-shot, tmux is not using any magic, the split is still a single character wide column. The less obtrusive visual effect is the use of a Unicode box drawing character that is less clunky than vim's ASCII default, and the lack of a highlight background color. Very nearly the same effect is possible in vim by adding something like the ...


5

To send to another pane you'll need to call tmux from Vim. Specifically, you'll need the send-keys command (alias: send). For example, this will cause the current line number in Vim to be printed to the terminal in pane 2 using echo: :exe "!tmux send -t 2 'echo " . line(".") . "' Enter" Applying the same form to your command: :exe "!tmux send -t 2 'behave ...


4

Add this line to your tmux.conf file set -g default-terminal "screen-256color" Add the line below to you shells rc file in my case its my .zshrc if [[ $TERM == xterm ]]; then TERM=xterm-256color; fi Add the line below to your .vimrc set t_Co=256 The above configuration works for me, but if this fails try to follow this link for another methor to fix ...


4

Turns out this was a bug in Vim itself. The problem is resolved as of Vim 7.4.1942.


4

No, this cannot be done in Vim, and would probably be very hard to implement in GVIM. Vim sticks to the cell-based addressing used in the terminal; within a buffer, this is crucial for consistent vertical navigation with j / k. This addressing by cell-based x and y coordinates is so ingrained in Vim's implementation, I guess it's very hard to overcome. ...


4

Adding t_Co=256 to your vimrc should never be necessarily, save for some highly unusual and archaic situations. It's typically a sign that something else is set up wrong. By far the most common problem is a wrong TERM environment variable. You mentioned tmux, try using screen-256color, which should be the correct TERM for tmux. This is typically set in your ...


4

Here's an example of inserting line number in a shell command: :exe "!echo " . line(".") So your mapping would be something like this: nnoremap <silent> <leader>ef :exe "!tmux send -t 0.1 'mix test %:p:" . line(".") . "' Enter"<CR><C-L> I run tmux so I was able to test that the command appeared in a tmux pane (though I can't ...


4

Looks more like a shell related question than a Vim related question. I would try the following (not tested, so might be wrong): silent execute "!tmux send-keys -t " . _count . " -- \"" . text . "\"" Add a -- before the text. Most Unix commands stop option processing as soon as they see a -- and everything after it is handled as parameter.


3

I actually made it work just fine with termguicolors. This is what I did 1. in my ~/.bash_profile i put this: export TERM=xterm-256color and inside my ~/.vimrc I had this syntax enable colorscheme Spacegray set termguicolors and it worked perfectly! reference


3

After messing around a bit more and looking over some stuff I was able to get this to work by wrapping the external command and its parameters in an execute command then using the bar to send the redraw command. :execute "silent !tmux send -t 0.1 'ruby test.rb' Enter" | :redraw!


3

The correct value of $TERM environments variable is very important. Make sure that it is different from screen-256color. Set it to xterm-256color for example.


3

To restore the default tmux naming scheme when quitting vim you can also do: autocmd VimLeave * call system("tmux setw automatic-rename")


2

The reason why Ctrl-Home and Ctrl-End don't work for Vim inside of Tmux is because Tmux eats those inputs. To fix this you need to unbind the affected keys in your Tmux config wich is located at ~/.tmux.conf To unbind a key unbind-key -[key] So for your example: unbind-key C-Home unbind-key C-End


2

Use fakeclip.vim. See this answer for details.


2

Vim is able to use the same completion database if the database is external to each vim instance. For example, completion will be somewhat 'shared' if you use ctags completion or youcompleteme or any other plugin that uses external processes or files. Word completion is not quite useful for you because it will only use words in the same file: C-N/C-P But ...


2

Term creates new terminals with TERM=screen-256color Put this in your .bashrc to fix the issue export TERM=xterm-256color EDIT: As pointed out in the comments, you should probably run echo $TERM when you are not in tmux, then set export TERM= to whatever the output of echo was.


2

You can use Gbrowse! to get the url copied into the clipboard and then either paste it in the local browser or fire another :!ssh command from the remote machine to the local machine, like (from vim in the ssh session) :Gbrowse! | exe "!ssh $LOCAL 'nohup google-chrome " . @+ . "' &" change google-chrome to other browsers or xdg-open to use the default ...


2

This is obviously an opiniated question. Here's my opinion. Advantages of neovim (or Vim) terminal: Normal mode gives the power of Vim inside a terminal window Can use vimscript to customize mappings and commands Advantages of tmux: Allows persistent sessions IMHO this is the most important aspect of tmux, because: It allows to detach a session, then ...


2

I have this in my .vimrc, which works when running tmux in gnome-terminal if &term =~ '^tmux' let &t_BE="\<Esc>[?2004h" let &t_BD="\<Esc>[?2004l" let &t_PS="\<Esc>[200~" let &t_PE="\<Esc>[201~" endif Terminal in tmux is set to tmux-256color; fragment from ~/.tmux.conf: set -g default-terminal tmux-...


2

As D. Ben Knoble said in his comment, "you haven't left the buffer or entered insert mode when you switch, so it makes sense those don't trigger. And the help for FocusGained / Lost says: "Only for the GUI version and a few console versions where this can be detected." I guess the console never lost/gained focus as you switch tmux panes. So even if the ...


1

That's what I've done in lh-vim-lib lh#buffer#jump(). You'll have to adapt the ...#find() function to one that fits better your needs. " Function: lh#buffer#jump({filename},{cmd}) {{{2 function! lh#buffer#jump(filename, cmd) abort let b = lh#buffer#find(a:filename) if b != -1 || type(a:filename) == type(0) | return b | endif call lh#window#...


1

'titleold' string (default "Thanks for flying Vim") global This option will be used for the window title when exiting Vim if the original title cannot be restored. Only happens if 'title' is on or 'titlestring' is not empty. So autocmd VimLeave * set notitle should fix it.


Only top voted, non community-wiki answers of a minimum length are eligible