为什么Vim这么慢?
我是一个开始使用vim的用户,我有点困惑。看起来Vim比Geany慢。这是一个非常明显的区别。当我在Geany中按住任何键时,它会毫无延迟地打印它(例如llll)。在Vim中,它是缓慢和跳跃的。与Geany相比,vim中的Autocomplete非常可怕。我以为维姆和光速一样快。看起来不是。有什么建议可以改变这一点,让vim更快 这是我的vimrc文件:为什么Vim这么慢?,vim,Vim,我是一个开始使用vim的用户,我有点困惑。看起来Vim比Geany慢。这是一个非常明显的区别。当我在Geany中按住任何键时,它会毫无延迟地打印它(例如llll)。在Vim中,它是缓慢和跳跃的。与Geany相比,vim中的Autocomplete非常可怕。我以为维姆和光速一样快。看起来不是。有什么建议可以改变这一点,让vim更快 这是我的vimrc文件: " This must be first, because it changes other options as side effect s
" This must be first, because it changes other options as side effect
set nocompatible
" Use pathogen to easily modify the runtime path to include all
" plugins under the ~/.vim/bundle directory
call pathogen#helptags()
call pathogen#infect()
" change the mapleader from \ to ,
let mapleader=","
" Quickly edit/reload the vimrc file
nmap <silent> <leader>ev :e $MYVIMRC<CR>
nmap <silent> <leader>sv :so $MYVIMRC<CR>
set hidden
set nowrap " don't wrap lines
set tabstop=4 " a tab is four spaces
set backspace=indent,eol,start
" allow backspacing over everything in insert mode
set autoindent " always set autoindenting on
set copyindent " copy the previous indentation on autoindenting
set number " always show line numbers
set shiftwidth=4 " number of spaces to use for autoindenting
set shiftround " use multiple of shiftwidth when indenting with '<' and '>'
set showmatch " set show matching parenthesis
set ignorecase " ignore case when searching
set smartcase " ignore case if search pattern is all lowercase,
" case-sensitive otherwise
set smarttab " insert tabs on the start of a line according to
" shiftwidth, not tabstop
set hlsearch " highlight search terms
set incsearch " show search matches as you type
set history=1000 " remember more commands and search history
set undolevels=1000 " use many muchos levels of undo
set wildignore=*.swp,*.bak,*.pyc,*.class
set title " change the terminal's title
set visualbell " don't beep
set noerrorbells " don't beep
set nobackup
set noswapfile
filetype plugin indent on
autocmd filetype python set expandtab
if &t_Co >= 256 || has("gui_running")
colorscheme badwolf
endif
if &t_Co > 2 || has("gui_running")
" switch syntax highlighting on, when the terminal has colors
syntax on
endif
" Vim can highlight whitespaces for you in a convenient way:
set list
set listchars=tab:>.,trail:.,extends:#,nbsp:.
set pastetoggle=<F2>
set mouse=a " Enable mouse
set encoding=utf-8
set langmenu=en_US
let $LANG = 'en_US'
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
set autochdir " working directory is always the same as the file you are editing
noremap <F5> :w !python %<CR>
inoremap <F5> <ESC>:w !python %<CR>
nmap <leader>t :NERDTree<CR>
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
set guifont=Hack:h10:cDEFAULT
let g:Powerline_symbols = 'fancy'
set laststatus=2
python from powerline.vim import setup as powerline_setup
python powerline_setup()
python del powerline_setup
filetype plugin on
set omnifunc=syntaxcomplete#Complete
au CompleteDone * pclose
set completeopt=longest,menuone,preview
set guioptions-=T
set nofoldenable " disable folding
nmap <silent> ,/ :nohlsearch<CR>
“这必须是第一个选项,因为它会改变其他选项作为副作用
兼容模式
“使用此选项可以轻松修改运行时路径以包含所有
“~/.vim/bundle目录下的插件
调用病原体#helptags()
叫病原体#传染()
“将mapleader从\更改为,
让mapleader=“,”
“快速编辑/重新加载vimrc文件
nmap ev:e$MYVIMRC
nmap sv:so$MYVIMRC
隐藏
设置nowrap“不换行
设置tabstop=4“一个制表符有四个空格
设置退格=缩进、下线、开始
“允许在插入模式下对所有内容进行退格
设置自动缩进”始终将自动缩进设置为打开
set copyindent“在自动缩进时复制上一个缩进
“设置编号”始终显示行号
设置shiftwidth=4“用于自动缩进的空格数
设置SHIFTROND“使用“”缩进时使用shiftwidth的倍数”
设置显示匹配”设置显示匹配括号
设置ignorecase“搜索时忽略大小写”
设置smartcase“如果搜索模式均为小写,则忽略大小写,
“区分大小写
设置smarttab“在行首插入制表符,根据
“移动两次,而不是停止
设置hlsearch“突出显示搜索词
set incsearch“键入时显示搜索匹配项
设置历史记录=1000“记住更多命令并搜索历史记录
设置撤消级别=1000“使用多个撤消级别
设置wildignore=*.swp、*.bak、*.pyc、*.class
设置标题“更改终端标题
设置visualbell“不发出哔哔声
设置noerrorbells“不发出哔哔声
设置备份
设置noswapfile
文件类型插件缩进
autocmd文件类型python集expandtab
如果&t_Co>=256||has(“gui_运行”)
颜色方案恶狼
恩迪夫
如果&t_Co>2||has(“gui_运行”)
当终端有颜色时,打开语法高亮显示
语法高亮
恩迪夫
“Vim可以方便地为您突出显示空白:
集合列表
设置listchars=tab:>,trail:,extends:#,nbsp:。
设置粘贴切换=
设置鼠标=启用鼠标
设置编码=utf-8
设置langmenu=en_US
让$LANG='en_US'
来源$VIMRUNTIME/delmenu.vim
来源$VIMRUNTIME/menu.vim
set autochdir“工作目录始终与您正在编辑的文件相同
诺雷马克:w!蟒蛇%
伊诺雷玛:w!蟒蛇%
nmap:NERDTree
autocmd bufenter*if(winnr(“$”==1&&exists(“b:NERDTreeType”)&&b:NERDTreeType==primary”)| q | endif
设置guifont=Hack:h10:cDEFAULT
设g:Powerline_符号='fancy'
设置laststatus=2
python从powerline.vim导入设置为powerline\u设置
python电力线安装程序()
python del电力线安装程序
上的文件类型插件
set omnifunc=syntaxcomplete#Complete
au CompleteDone*pclose
set completeopt=最长、菜单单、预览
设置guioptions-=T
设置nofoldenable“禁用折叠
nmap,/:nohlsearch
可能是很多事情,不一定是Vim的错。实际上,不太可能是Vim的错
Vim-u NONE
运行,并注释掉.vimrc中的所有内容,然后做一件看起来很慢的事情-u NONE
的情况下运行并进行比较。它应该同样快,或者某个插件自动加载并导致问题。如果是这样,请尝试暂时将文件从~/.vim/bundle
目录中移出另一个问题可能是缓慢的终端和/或驱动程序(因此将Vim与GVim进行比较)。如果您有一个具有奇特字体、透明度、小字体和大屏幕大小的缓慢终端,那么终端可能非常非常非常慢。如果您像我一样在终端中使用Vim(而不是GVim),我刚刚发现,尝试一下,它看起来非常好: 将此添加到~/.vimrc中: 设置timeoutlen=1000 设置ttimeoutlen=0 在~/.screenrc中,这一点(甚至更重要): 映射超时0
既然我这样做了,一切都好了。在我将以下配置添加到我的vimrc后,我的vim开始运行,当你让vim整天/一周运行并经常打开和关闭许多不同的文件时,这非常有用
function! CloseHiddenBuffers()
" >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
" close any buffers hidden
" <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
let open_buffers = []
for i in range(tabpagenr('$'))
call extend(open_buffers, tabpagebuflist(i + 1))
endfor
for num in range(1, bufnr("$") + 1)
if buflisted(num) && index(open_buffers, num) == -1
exec "bdelete ".num
endif
endfor
endfunction
au BufEnter * call CloseHiddenBuffers()
函数!CloseHiddenBuffers()
" >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
“关闭所有隐藏的缓冲区
“我遇到了一个类似的问题,粘贴文本段落或只是以典型的速度打字都会让vim死机
您可以对.vimrc
进行故障排除,如果是,请查看哪些插件速度较慢。您还可以跳过故障排除和使用,它与vim和asynchronous完全兼容
一旦我开始使用它,我的输入延迟问题就消失了。它使用一个异步库libuv
,它是。我使用与vim相同的.vimrc
(复制到~/.config/nvim/init.vim
),因此这不是不同插件的问题。我在Ubuntu 20.04和Macos 10.14上也看到了这种响应能力的改进
我发布这个答案是因为我希望它在我上次阅读这个问题时就已经存在。这是您的vimrc文件的一个问题。首先尝试在不使用的情况下运行它,并查看它是否有影响:<