gpt4 book ai didi

c++ - 如何为vim应用语法文件?

转载 作者:太空狗 更新时间:2023-10-29 20:25:15 25 4
gpt4 key购买 nike

我已经阅读了 vim 手册页和一堆教程,并设法在 vim 中设置了我的 C++ 环境,但是应用语法文件可能是科幻小说。

我下载了一个“cpp.vim”,它是一个语法文件,现在我该如何应用该文件让我的代码开始发光??

我尝试将文件放入以下目录:

~/.vim/after/syntax/

~/.vim/语法

/usr/share/vim/vim73/语法(但名称不同,所以不替换旧文件)

这些都不起作用,无论如何,如果我用一些疯狂的名字将文件放入 $VIMRUNTIME/syntax,那么我如何将它应用到 vim 中?

这是我的 .vimrc 设置:

"
" vim settings
"

set t_Co=256
set nocompatible
set laststatus=2

"set ruler
"set ballooneval
"set balloondelay=400
"set balloonexpr=""


filetype off


"
" vundle settings and plugins
"


set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

"Vundle Plugin manager
Plugin 'gmarik/Vundle.vim' "vundle plugin manager

"Core plugins
Plugin 'ervandew/supertab' "completition with tab
Plugin 'scrooloose/syntastic' "error checking
Plugin 'vim-scripts/OmniCppComplete' "auto complete
"Plugin 'octol/vim-cpp-enhanced-highlight' "syntax highlighting
Plugin 'vim-scripts/Cpp11-Syntax-Support'
Plugin 'bling/vim-airline' "statusline and tabline

"Sipet plugins
Plugin 'MarcWeber/vim-addon-mw-utils' "required by snipmate
Plugin 'tomtom/tlib_vim' "required by snipmate
Plugin 'garbas/vim-snipmate' "insert snipets
Plugin 'honza/vim-snippets' "optional snipets


Plugin 'vim-scripts/a.vim' "Switching between source and header file
Plugin 'chazy/cscope_maps' "Allows searching code
Plugin 'vim-scripts/argtextobj.vim' "Text-object like motion for arguments
Plugin 'wincent/Command-T' "Fast file navigation
Plugin 'vim-scripts/taglist.vim' "Source code browser (requires exuberant-ctags > apt-get install)


Plugin 'ddollar/nerdcommenter' "wrangle your code comments, regardless of filetype
Plugin 'scrooloose/nerdtree' "explore your filesystem and to open files and directories
Plugin 'tpope/vim-unimpaired' "provides a lot of useful mappings
Plugin 'majutsushi/tagbar' "browsing the tags of source code files
Plugin 'chrisbra/NrrwRgn' "focussing on a region and making the rest inaccessible
Plugin 'vim-scripts/ZoomWin' "zoom into a window and out again
Plugin 'terryma/vim-multiple-cursors'
Plugin 'jeetsukumaran/vim-buffergator' "listing,navigating, and selecting buffers for edit
Plugin 'bronson/vim-trailing-whitespace' "causes all trailing whitespace to be highlighted in red

Plugin 'mileszs/ack.vim' "uses ack to search inside the current directory for a pattern
Plugin 'myusuf3/numbers.vim' "intelligently toggling line numbers
Plugin 'Lokaltog/vim-easymotion' "provides a much simpler way to use some motions in vim

call vundle#end()
filetype plugin indent on


"
" ariline options
"

let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'



"
" syntastic settings
"

let g:syntastic_enable_signs = 1
let g:syntastic_cpp_checkers = ['gcc']

let g:syntastic_auto_jump = 1
let g:syntastic_enable_balloons = 1

let g:syntastic_cpp_compiler = 'g++'
let g:syntastic_cpp_compiler_options = '-std=c++11'


let g:syntastic_cpp_check_header = 1
let g:syntastic_cpp_auto_refresh_includes = 1


let g:syntastic_always_populate_loc_list = 1

syntax on
colorscheme slate

...等等

其他选项是插件和插件设置..

问题很简单,如何应用语法文件??

最佳答案

您需要做的就是确保正确加载文件类型。因此,如果语法文件名为 cpp.vim,请确保 set ft? 返回 cpp。你应该把它放在 $HOME/.vim/syntax 中。它应该自动加载。假设设置了 filetype onsyntax on

确保语法文件未正确加载的唯一方法是使用 :scriptnames。如果您遇到的问题与您描述的不同,请确保未列出该文件。

关于c++ - 如何为vim应用语法文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24464111/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com