77
votes
Accepted
How to map Alt key?
That's how I do it on Linux or Cygwin:
First check what chars are sent by your terminal when you press ALT+J:
In order to do this I go to console and run sed -n l (you can also use cat for it). Then I ...
44
votes
Can Vim interpret terminal color escape codes?
There are various plugins which allow you to view ANSI colours through escape codes:
AnsiEsc.vim – :AnsiEsc.
Colorizer – :ColorToggle.
If you want to remove all escape codes, you could use:
:%s/<...
42
votes
Accepted
Can the split separator in vim be less than a full column wide?
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 ...
32
votes
Accepted
Can I use a non-monospaced font in either Vim or gVim?
I found mlterm, which supports this. Aside from Emacs' built-in terminal (M-x term) this is the only terminal I've found that supports this (I've tried about 15-20 different ones).
I've found that ...
30
votes
Terminal borked after invoking Vim with xargs
This happens when vim is invoked and it's connected to the previous pipeline's output, instead of the terminal and it's receiving different unexpected input (like NULs).
The same happens when you run: ...
27
votes
Accepted
Prevent Vim from clearing the terminal after exit
By default VIM, when terminating, sends the string configured with the option t_te to the hosting terminal to tell it to clear the screen. To avoid it just :set t_te= to send nothing to the terminal ...
21
votes
Accepted
How to label tmux tabs with the name of the file edited in vim?
There you go :
autocmd BufReadPost,FileReadPost,BufNewFile,BufEnter * call system("tmux rename-window 'vim | " . expand("%:t") . "'")
Decomposing :
autocmd BufReadPost,FileReadPost,BufNewFile,...
21
votes
Accepted
Why doesn't my numpad work right in my terminal?
Short answer
Turn off “application keypad mode switching.”
Terminal-specific instructions
PuTTY (also here):
Terminal > Features > uncheck Disable application keypad mode
SecureCRT:
Session ...
20
votes
Accepted
Tmux is changing part of the background in vim
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 ...
20
votes
Accepted
Scroll the screen, not the cursor, when using scrollwheel
As @Doorknob said in his comment, :set mouse=a fixes the problem.
19
votes
How to map Alt key?
With help of Carpetsmoker, it seems that Terminal wasn't configured to 'Use Alt/option as meta key' (this is especially common for GUI Terminals).
For Terminal on OSX, it's in Preferences -> ...
16
votes
Accepted
Detect neovim terminal from bash in bashrc
I compared the output of running env in a standard terminal to the output when running it within Neovim, and it looks like these variables are new:
VIMRUNTIME=/usr/local/Cellar/neovim/HEAD/share/nvim/...
16
votes
Accepted
How to restore bash terminal title if using 'set title' in vim?
Use the titleold setting:
" Update term title but restore old title after leaving Vim
set title
set titleold=
From :help 'titleold':
This option will be used for the window title when exiting Vim ...
13
votes
Terminal borked after invoking Vim with xargs
Workaround suggestion: use a buffer as a filesystem navigator
Use the vim - command to read a list of paths from stdin. Vim's :help -- explains this:1
Start editing a new buffer, which is filled ...
13
votes
Accepted
Number pad not working with vi and Putty?
Your terminal (PuTTY) is configured to send escape sequences for keypad keys, rather than digits. This is called “application keypad mode” in Unix terminal terminology.
You can configure Vim to ...
13
votes
How could I create a terminal at the bottom
In your ~/.vimrc add the line
set splitbelow
This will cause all splits to happen below (including terminal).
To change the height of the terminal (row x col)
set termwinsize=10x0 " 'termsize' ...
12
votes
Can Vim interpret terminal color escape codes?
If you have a sufficiently modern vim that has the +terminal feature, you can do :term cat somefile and you'll get a buffer with all the terminal codes interpreted.
This might work better on large ...
12
votes
Accepted
How to specify the content of a new buffer from command line?
Did you try something like this?
$ echo "foo, bar, baz, and qux" | vim -
Or like that?
$ vim -c "put='foo, bar, baz, and qux'"
12
votes
Accepted
Up arrow key code, why '^[[A' becomes '^[OA'?
You can paste Vim's builtin termcap database in the current buffer with the following command:
put =execute('set termcap')
In it, you should find the text t_ku <Up> ^[OA, which means that when ...
11
votes
How to map Alt key?
Similar to Kossak's answer but a bit simpler, by mapping literal key presses.
Either in normal mode after pressing :, or inserted into your .vimrc, map the input directly by starting the mapping:
...
11
votes
Detect neovim terminal from bash in bashrc
Aside from alxndr's example, you can set one yourself with:
:let $IN_NEOVIM = "yes"
:terminal
$ env | grep NEOVIM
IN_NEOVIM=yes
This is especially useful as a simple way to pass information to the ...
11
votes
VIM: how to send entire line to a buffer of type "Terminal"?
Here is a solution using Vim's term_sendkeys()
open a vim terminal and start the REPL
check which buffer the terminal is in with :ls
this example assumes the terminal is in buffer 2
cmd to copy the ...
11
votes
Accepted
How to run internal vim terminal at current file's dir?
I am grateful to @statox for useful hints, but as I don't wont to change current dir each time I come to following:
map <F6> :let $VIM_DIR=expand('%:p:h')<CR>:terminal<CR>cd $...
11
votes
Accepted
Opening :terminal window in new buffer
Thanks to Christian Brabandt, :ter ++curwin was the thing that I want.
11
votes
Accepted
how to change local directory of terminal buffer whenever its shell change directory
Create a special function in your vimrc that's callable from terminal, its name must start with Tapi_.
" arglist : [ cwd ]
" change window local working directory
function! Tapi_lcd(bufnum, arglist)
...
11
votes
Ctrl-W at :terminal (default terminal behavior expected)
You can set 'termwinkey' to a sequence other than <C-W> to use a different keystroke to access the special sequences on the terminal.
For example:
set termwinkey=<C-X>
Or:
set ...
10
votes
Colorscheme's background not correct in terminal
There's two reasons why I think this may be happening:
The solarized color scheme you are using does not declare ctermfg and ctermbg for any of the features you want to highlight. Try out this color ...
10
votes
Accepted
Mapping Ctrl+s does not work
To ensure that this workaround runs even when Vim is started by a separate tool (such as git), I have this in my ~/.vimrc:
" Allow us to use Ctrl-s and Ctrl-q as keybinds
silent !stty -ixon
&...
10
votes
Accepted
Use case for neovim terminal emulator?
Running a terminal inside Vim allows you to use Vim commands on the input and output to the programs that you run in that terminal. You get search, copy-paste, macros, syntax coloring, etc. Using :...
10
votes
How could I create a terminal at the bottom
This question is a couple of years old now but I found it when I was looking for a way to open a terminal inside vim below a bunch of vertical splits. What I want looks something like this:
+----+----+...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
terminal × 389neovim × 60
vimrc × 49
key-bindings × 43
colorscheme × 42
terminal-buffer × 37
macos × 20
vimscript × 18
cursor × 16
gvim × 15
microsoft-windows × 15
shell × 14
syntax-highlighting × 13
tmux × 12
color × 11
vim8 × 11
external-command × 10
linux × 10
iterm2 × 10
mouse × 9
command-line × 8
buffers × 8
cut-copy-paste × 8
vim-windows × 8
macvim × 7