Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/vim/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
不同语言和任务的不同vim文件_Vim_Vim Plugin_Vim Syntax Highlighting - Fatal编程技术网

不同语言和任务的不同vim文件

不同语言和任务的不同vim文件,vim,vim-plugin,vim-syntax-highlighting,Vim,Vim Plugin,Vim Syntax Highlighting,我想为vim中的不同任务创建不同的vim文件。我知道您可以创建不同的vim文件,这些文件可以根据文件扩展名动态加载。我的问题是我使用vundle来维护插件,我真的不知道如何在不同的文件中分离这些插件 我搜索了关于分离vim的内容,发现可以使用ftplugin,比如ftplugin/python.vim或ftplugin/matlab.vim。但我不知道我应该在每个.vim文件中编写vundle部分,还是所有内容都应该在一个vim文件中。 如果你需要更多信息,请告诉我。下面是我当前的.vimrc文

我想为vim中的不同任务创建不同的vim文件。我知道您可以创建不同的vim文件,这些文件可以根据文件扩展名动态加载。我的问题是我使用vundle来维护插件,我真的不知道如何在不同的文件中分离这些插件

我搜索了关于分离vim的内容,发现可以使用ftplugin,比如ftplugin/python.vim或ftplugin/matlab.vim。但我不知道我应该在每个.vim文件中编写vundle部分,还是所有内容都应该在一个vim文件中。 如果你需要更多信息,请告诉我。下面是我当前的.vimrc文件

" Configuration file for vim
set modelines=0     " CVE-2007-2438

" Normally we use vim-extensions. If you want true vi-compatibility
" remove change the following statements
set nocompatible    " Use Vim defaults instead of 100% vi compatibility
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')

"===================================================================
"Plugins 
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'

" For autocomplete
Bundle 'Valloric/YouCompleteMe'

" For folding 
Plugin 'tmhedberg/SimpylFold'

" For indent python
Plugin 'vim-scripts/indentpython.vim'

" For syntax
Plugin 'w0rp/ale'
" Check Python files with flake8 and pylint.
let b:ale_linters = ['flake8', 'pylint']
" Fix Python files with autopep8 and yapf.
let b:ale_fixers = ['autopep8', 'yapf']
" Disable warnings about trailing whitespace for Python files.
let b:ale_warn_about_trailing_whitespace = 0
syntax on

" For color Schemes
"Plugin 'jnurmine/Zenburn'
Plugin 'flazz/vim-colorschemes'
Plugin 'morhetz/gruvbox'

" For PowerLine
"Plugin 'powerline/powerline', {'rtp': 'powerline/bindings/vim/'}
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'

"For the nerd tree 
Plugin 'scrooloose/nerdtree'

" add all your plugins here (note older versions of Vundle
" used Bundle instead of Plugin)

" ...

" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required

"===================================================================
" For UTF-8
set encoding=utf-8

"System Clipboard
if has('mac')
    set clipboard=unnamed
elseif has('unix') 
    set clipboard=unnamedplus
endif

"set Line Numbering
set nu

"to handle the backspace problem
set bs=2

"Set up mouse 
set mouse=a 

"For Highlighting searched text
set hlsearch

"For confirming before exit (save)
set confirm

"Maping Ctrl+A for select all 
map <C-a> <esc>ggVG<CR>

"===================================================================
" Mapping NERDtree toggling 
nmap <F6> :NERDTreeToggle<CR>

"===================================================================
"Few settings for plugins 

" colorscheme 
colorscheme py-darcula

" to see the docstrings for folded code
let g:SimpylFold_docstring_preview=1
let mapleader=" "

"The first line ensures that the auto-complete window goes away when you’re
"done with it, and the second defines a shortcut for goto definition (second
"one I need to learn)
let g:ycm_autoclose_preview_window_after_completion=1
let g:ycm_min_num_of_chars_for_completion = 1
"map <leader>g  :YcmCompleter GoToDefinition<CR>

"To handle vitural env for YCM 
let g:ycm_python_binary_path = 'python3'

vim的配置文件 设置模型线=0“CVE-2007-2438 “通常我们使用vim扩展。如果您想要真正的vi兼容性 “删除并更改以下语句 设置nocompatible“使用Vim默认值而不是100%vi兼容性 “文件类型关闭”是必需的 “将运行时路径设置为包括Vundle和initialize 设置rtp+=~/.vim/bundle/Vundle.vim 调用vundle#begin() 或者,传递Vundle安装插件的路径 “调用vundle#begin(“~/some/path/here”) "=================================================================== “插件 “让Vundle管理Vundle,这是必需的 插件'gmarik/Vundle.vim' “为了自动完成 捆绑“Valloric/YouCompleteMe” “用于折叠 插件“tmhedberg/SimpylFold” “对于缩进python 插件“vim脚本/indentpython.vim” “对于语法 插件“w0rp/ale” “使用flake8和pylint检查Python文件。 让b:ale_linters=['flake 8','pylint'] “使用autopep8和yapf修复Python文件。 设b:ale_fixers=['autopep8','yapf'] “禁用有关Python文件尾部空白的警告。 让b:ale\u警告\u关于\u尾随\u空格=0 语法高亮 “用于配色方案 “插件'jnurmine/Zenburn' 插件'flazz/vim colorschemes' 插件“morhetz/gruvbox” “对于电力线 插件'powerline/powerline',{'rtp':'powerline/bindings/vim/'} 插件“vim航空公司/vim航空公司” 插件“vim航空公司/vim航空公司主题” “给书呆子树 插件'scroolose/nerdtree' “在此处添加所有插件(请注意Vundle的旧版本 “使用捆绑包而不是插件) " ... “所有插件都必须添加到下一行之前 需要调用vundle#end() “必需”上的文件类型插件缩进 "=================================================================== “对于UTF-8 设置编码=utf-8 “系统剪贴板 如果有('mac') 设置剪贴板=未命名 elseif有('unix') 设置剪贴板=未命名加号 恩迪夫 “设置行编号 显示行号 “处理退格问题 设置bs=2 “设置鼠标 设置鼠标=a “用于突出显示搜索的文本 高亮显示 “用于退出前确认(保存) 设定确认 “将Ctrl+A映射为全选” 地图ggVG "=================================================================== “映射NERDtree切换 nmap:nerdtreethoggle "=================================================================== “插件的设置很少 “配色方案 彩色达库拉 “查看折叠代码的文档字符串 设g:SimpylFold\u docstring\u preview=1 让mapleader=“” “第一行可确保在安装时自动完成窗口消失 完成后,第二个定义了转到定义的快捷方式(第二个) “一个我需要学习的) 让g:ycm\u自动关闭\u预览\u窗口\u完成后=1 设g:ycm_min_num_of_chars_for_completion=1 地图g:YcmCompleter GoToDefinition “为YCM处理vitural env 设g:ycm_python_binary_path='python3'
可以使用单独的配置文件(您可以通过
-u{vimrc}
命令行参数覆盖默认的
.vimrc
;shell别名可以使这非常容易)。然而,对于大多数用户来说,这种复杂性应该不是必需的

特别是,Vim以缓冲区本地选项和文件类型插件的形式内置了不同类型文件的设置范围。因此,如果您希望Python与文本文件的缩进不同,那么这应该是现成的。即使您正在全局安装一个插件,如
vim scripts/indentpython.vim
(在您的情况下通过Vundle),它也只会在
:setlocal filetype?
返回
python
的文件上激活。(顺便说一句,该插件最近一次更新是在9年前,Vim现在附带了一个积极维护的
$VIMRUNTIME/indent/python.Vim

对于全局插件,总是安装它们通常不会有什么坏处,即使您可能只在某些项目中使用它们。Vim的机制动态地包括按需提供的主要插件功能,以缩短Vim的启动时间。激活不同的插件集只对极少数高级用户有意义(他们已经对Vim的插件机制有了非常深入的了解,不需要问这样的问题)


您将在和上找到有关此的更多信息。

据我所知,现有的插件工作正常,但您想知道编写自己的插件的正确方法。我说得对吗

如果是这样,那么您不必编写与Vundle或任何其他插件管理器相关的插件(或其他vim文件)。您所需要的只是:

  • 阅读
    :帮助rtp
  • 在任何需要的地方为文件创建文件夹
  • 设置新文件夹的
    runtimepath
    选项。通常,它只是使用
    +=
    操作符添加新路径
  • 了解搜索运行时文件的目录列表,创建您想要获得的功能
还有一次:如果您正在编写自己的vim文件,请离开Vundle。文德尔,
与任何其他插件管理器一样,它只是一个方便的工具,可以从github存储库中检索代码,并根据新数据设置
rtp
选项。

您希望在这些文件中执行什么操作?是否设置了一些选项,如间距和缩进?添加特定于语言的函数?还有别的吗?你不可以