【linux】Vim配置问题
vim配置好后, 按回车就会出现一个斜杠, 且缩进2个Tab, 配置文件如下:
set nocompatible2
3 set number
4
5 " 隐藏滚动条"
6 set guioptions-=r
7 set guioptions-=L
8 set guioptions-=b
9
10 "隐藏顶部标签栏"
11 set showtabline=0
12
13
14 "设置字体"
15 set guifont=Monaco:h13
16
17 syntax on
18
19 set cindent "设置C样式的缩进格式"
20 set tabstop=4 "设置table长度"
21 set shiftwidth=4 "同上"
22 set showmatch "显示匹配的括号"
23 set scrolloff=5 "距离顶部和底部5行"
24
25 set cursorline "突出显示当前行"
26
27
28 let g:solarized_termcolors=256
29 set background=dark "设置背景色"
30
31 set selection=exclusive
32 set selectmode=mouse,key
33 set matchtime=5
34 set ignorecase "忽略大小写"
35 set incsearch
36 set hlsearch "高亮搜索项"
37 set noexpandtab "不允许扩展table"
38 set whichwrap+=<,>,h,l
39 set autoread
40
41 map <F5> :Autopep8<CR> :w<CR> :call RunPython()<CR>
42 function RunPython()
43 let mp = &makeprg
44 let ef = &errorformat
45 let exeFile = expand("%:t")
46 setlocal makeprg=python\ -u
47 set efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m
48 silent make %
49 copen
50 let &makeprg = mp
51 let &errorformat = ef
52 endfunction
54 filetype off
55 set rtp+=~/.vim/bundle/Vundle.vim
56 call vundle#begin()
57 Plugin 'Valloric/YouCompleteMe'
58 Plugin 'scrooloose/nerdtree'
59 Plugin 'Yggdroot/indentLine'
60 Plugin 'tell-k/vim-autopep8'
61 Plugin 'jiangmiao/auto-pairs'
62 Plugin 'VundleVim/Vundle.vim'
63 Plugin 'Lokaltog/vim-powerline'
64 Plugin 'scrooloose/nerdcommenter'
65 Plugin 'L9'
66 call vundle#end()
67 filetype plugin indent on
68
69 "默认配置文件路径"
70 let g:ycm_global_ycm_extra_conf = '~/.ycm_extra_conf.py'
71
72 "打开vim时不再询问是否加载ycm_extra_conf.py配置"
73 let g:ycm_confirm_extra_conf=0
74 set completeopt=longest,menu
75 "python解释器路径"
76 let g:ycm_path_to_python_interpreter='/usr/bin/python3'
77 ""是否开启语义补全"
78 let g:ycm_seed_identifiers_with_syntax=1
79 "是否在注释中也开启补全"
80 let g:ycm_complete_in_comments=1
let g:ycm_collect_identifiers_from_comments_and_strings = 0
82 ""开始补全的字符数"
83 let g:ycm_min_num_of_chars_for_completion=2
84 "补全后自动关机预览窗口"
85 let g:ycm_autoclose_preview_window_after_completion=1
86 "" 禁止缓存匹配项,每次都重新生成匹配项"
87 let g:ycm_cache_omnifunc=0
88 "字符串中也开启补全"
89 let g:ycm_complete_in_strings = 1
90 ""离开插入模式后自动关闭预览窗口"
91 autocmd InsertLeave * if pumvisible() == 0|pclose|endif
92 "回车即选中当前项"
93 inoremap <expr> <CR> pumvisible() ? '<C-y>' : '\<CR>'
94
95 ""上下左右键行为"
96 inoremap <expr> <Down> pumvisible() ? '\<C-n>' : '\<Down>'
97 inoremap <expr> <Up> pumvisible() ? '\<C-p>' : '\<Up>'
98 inoremap <expr> <PageDown> pumvisible() ? '\<PageDown>\<C-p>\<C-n>' : '\<PageDown>'
99 inoremap <expr> <PageUp> pumvisible() ? '\<PageUp>\<C-p>\<C-n>' : '\<PageUp>'
100 let g:Powerline_symbols = 'fancy'
101 set laststatus=2
102
103
104 "F2开启和关闭树"\
105 map <F2> :NERDTreeToggle<CR>
106 let NERDTreeChDirMode=1
107 ""显示书签"\
108 let NERDTreeShowBookmarks=1
109 "设置忽略文件类型"\
110 let NERDTreeIgnore=['\~$', '\.pyc$', '\.swp$']
111 ""窗口大小"\
112 let NERDTreeWinSize=25
回答
92 "回车即选中当前项"93 inoremap <expr> <CR> pumvisible() ? '<C-y>' : '\<CR>'
这两行如果功能不需要的话
然后我测试了一下这个功能在我的vim上是能够正常运行的. 可能是你的别的插件和这行冲突了.
试一下 :verbose imap <CR>
, 看回车键是否被修改。如何
debug vim 的键位映射, https://vi.stackexchange.com/... .
另外,用 vim 写 Python 的话,可以看一下我这篇文章: 用 Vim 写 Python 的最佳实践 。
以上是 【linux】Vim配置问题 的全部内容, 来源链接: utcz.com/a/85567.html