Vim in terminal is slow - linux

I'm using vim in the terminal a log and I'm getting frustrated with its slow performance. I'm on Debian Jessie using Gnome.
If I open a file in vim do a block select and I to insert on multiple lines there is always a delay from when I press esc to when the change is inserted.
If I do the the same thing in gvim the change is imidiate.
I have tried adding
set ttyfast
set lazyredraw
In my ~/.vimrc but that does not make any noticeable difference.
$ vim --verion
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Nov 20 2015 15:31:14)
Included patches: 1-930

This is completely normal.
In Vim, some special keys (like the cursor keys) are implemented as <Esc> followed by some other character. Therefore, Vim waits a bit after your press <Esc> to determine if you actually wanted <Esc> or if you wanted something else like <Esc>A (<Up>).
See :help 'timeout', :help 'timeoutlen', :help 'ttimeout', and :help 'ttimeoutlen'.

Related

what are the commands that can work in vi and not in vim?

Vim is an ascendant text editor to vi and is 99% compatible to the latter can someone tell me what is the 1%. I mean the command that can be executed in vi mode and not in vim.
You'll find the list at :help vi-differences. The only noted omission from Vim is the open mode; in Vim, :open is only emulated.
The runtime behavior can be controlled via the 'cpoptions' option; each letter in it stands for one vi-compatibility; most are turned off in Vim-mode (i.e. with :set nocompatible, or when a .vimrc file is found).

Insert mode arrow keys make letters

In vim, when I am in insert mode and press the arrow keys I get letters instead:
As you can see, the arrow keys, when pressed, insert a line above the current cursor position including either A, B, C or D.
How do I stop this?
Things I've tried
I have set nocompatible in my ~/.vimrc (vimrc pastebin), I am using pathogen and here is my ~/.vim/bundle directory:
YouCompleteMe/
emmet-vim/
nerdtree/
node/
vim-airline/
vim-markdown/
The problem only started recently, but I can't think of what caused it.
I've done :set term=builtin_ansi, and this fixes the problem but removes all my colors.
$ vim --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Aug 29 2016 12:51:13)
MacOS X (unix) version
Included patches: 1-2290
Compiled by Homebrew
Huge version without GUI. Features included (+) or not (-):
...
See http://pastebin.com/5z1HbpqW for the whole output.
$ echo $TERM
xterm-256color
and in vim:
:set compatible?
nocompatible
:set term?
term=xterm-256color
Use this:
:set term=builtin_ansi
Source: http://vim.wikia.com/wiki/Fix_broken_arrow_key_navigation_in_insert_mode

VIM cmdline completion after '#' (hash key)

SETUP
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Mar 31 2015 23:35:48)
Included patches: 1-488, 576
Modified by pkg-vim-maintainers#lists.alioth.debian.org
set wildmode?
wildmode=list:longest,full
some plugins: i.e. UltiSnips
Problem
when typing a :call command, where I'd like to invoke some routine of a plugin directely, cmdline completion (with TAB key, by default) stops after the #.
i.e.: I want to complete :call UltiSnips#ListSnippets()
where many other UltiSnips routines are available.
When typing :call ult and press TAB, I get:
:call UltiSnips# with a listing of all possible matches.
When I press TAB further, it toggles through all matches correctely
BUT if I try to contiue typing the function name like :call UltiSnips#List and hit TAB, it wont complete the funtion's name, but ANY completion, that is starting with List (what I typed after the #; ListTemplateSuffixes( in my case)
This has been fixed by recent Vim patch 7.4.516: issue 253: completing function name with a # does not work.
So, you just need to update your Vim (by compiling it yourself; or just wait until your distribution provides such upgrade).

Vim key mapping works in command editor, not in .vimrc - why?

When I create the following key mapping via the command buffer it works as expected moving the cursor 5 lines down:
map ^[[1;3B 5<Down>
When I add it to my .vimrc file so that it works across sessions, pressing Alt+Down moves backwards 1 line (to somewhere not vertically above - maybe it's going to a previous sentence). My :map output is this:
0 ^
^[[1;3B 5<Down>
n gx <Plug>NetrwBrowseX
n <Plug>NetrwBrowseX * :call netrw#NetrwBrowseX(expand("<cWORD>"),0)<CR>
Press ENTER or type command to continue
Why doesn't this vimrc mapping work similarly to what I type in the command buffer?
My version of vim is:
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan 10 2014 00:22:49)
Included patches: 1-135
Compiled by <cygwin#cygwin.com>
UPDATE
There are 2 issues.
my version of Vim doesn't understand map <M-Down> 5<Down> but does understand map <M-Down> 5j
Something in my .vimrc file prevents map <M-Down> 5j from working. I had to put a bunch of hacks in to get "normal" vim behavior in my Cygwin environment:
"==================
" Keyboard trouble
"=================
" Every so often I am using a system that inserts a A, B, C, or D
" when using the arrow keys within the Vim editors insert mode.
" Vim is for VI Improved. While I did not dig into the exact reasons
" as to why (terminal emulation?) it happens, it is quite annoying.
set nocompatible
"set term=cons25
" This fixes Cygwin's vim's page up, home, end etc. keys
" http://superuser.com/questions/480215/
" how-to-map-pagedown-and-pageup-keys-to-function-normally
set term=mintty
set backspace=2 " backspace on Cygwin Windows Objy was not deleting properly.
" But this doesn't solve other cursor movements like
"home and end
"source /home/sarnobat/.vim/cscope_maps.vim
"g:CCTreeCscopeDb = "/home/sarnobat/cscope/cscope.files"
"==============================
" Key bindings
"==============================
map 0 ^
I don't understand those characters: ^[[1;3B. In vim you can choose the Alt key as letter M and the arrow letter as down, so:
map <M-down> 5<Down>
will work in either command-line and from your vimrc file.
you could try the following:
map <M-down> 5j
Tried it on cygwin and it worked. hjkl is the preferred method of navigating left, down, up and right.

Why doesn't "map! <C-q> :q <CR> " work in vim?

I input :map! <C-q> :q <CR> in command line mode, then return to normal mode, and press ctrl-q, but vim does not quit. Why?
As Johnsyweb suggested, Ctrl-Q does not reach Vim in the first place. This holds for the popular Ctrl-S as well. Both can be fixed by adding
silent !stty -ixon > /dev/null 2>/dev/null
to your .vimrc as it forces these control sequences to reach the application.
Why anyone would want to add yet another way of quitting Vim to the plethora already available is beyond me. However...
On Fedora 15, Ctrl-Q is likely being captured by your terminal as XON (resume) and therefore not reaching Vim to quit the application.
You can check if there's an error in your mapping or a clash like so:
:verbose map! <C-Q>
:map! is for specifing mappings in insert and command-line modes.
normal-mode mappings are (usually) specified like so:
:nmap <C-Q> :q<CR>

Resources