首页 \ 问答 \ vim中的语法高亮显示不起作用(Syntax highlight in vim not working at all)

vim中的语法高亮显示不起作用(Syntax highlight in vim not working at all)

我刚刚在这个这个源代码的帮助下忙着配置vim看起来像一个IDE,但我似乎无法让语法突出显示工作。

在我的~/.vimrc我有以下两个设置filetype plugin indent onsyntax on应该突出语法,但每当我打开一个文件(例如JavaScript)它不起作用。

当我打开文件,并执行:syntax list我收到以下响应: No syntax items defined for this buffer

我(快速)在互联网上搜索是指我提到的设置(和正确定义)。

我错过了什么?

在我的整个.vimrc内容下面

set nocompatible

"""" Config Vundle plugin manager """""
filetype off

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

Plugin 'VundleVim/Vundle.vim'

"""" Plugins """"
Plugin 'altercation/vim-colors-solarized'
Plugin 'tomasr/molokai'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'scrooloose/nerdtree'
Plugin 'jistr/vim-nerdtree-tabs'
Plugin 'vim-syntastic/syntastic'
Plugin 'xolox/vim-misc'
Plugin 'xolox/vim-easytags'
Plugin 'majutsushi/tagbar'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'vim-scripts/a.vim'
Plugin 'airblade/vim-gitgutter'
Plugin 'tpope/vim-fugitive'
Plugin 'Raimondi/delimitMate'
Plugin 'jez/vim-superman'
Plugin 'christoomey/vim-tmux-navigator'
Plugin 'jez/vim-c0'
Plugin 'jez/vim-ispc'
Plugin 'kchmck/vim-coffee-script'
Plugin 'godlygeek/tabular'
Plugin 'HTML-AutoCloseTag'
Plugin 'ekalinin/Dockerfile.vim'
Plugin 'cakebaker/scss-syntax.vim'
Plugin 'tpope/vim-surround'
Plugin 'ntpeters/vim-better-whitespace'
Plugin 'edkolev/tmuxline.vim'

"""" OSX stupid backspace fix """"
set backspace=indent,eol,start

call vundle#end()
filetype plugin indent on
syntax on

"""" General settings """"
set backspace=indent,eol,start
set ruler
set number
set showcmd
set incsearch
set hlsearch

"""" Set tabs """"
set tabstop=2
set shiftwidth=2
set smarttab
set expandtab

"""" Enable mouse support """"
set mouse=a

"""" Enable highlighting of the current line """"
set cursorline

"""" Support symbols in the title bar """"
hi clear SignColumn

"""" Colorscheme (Solarized) """"
set background=dark
colorscheme solarized

" Always show statusbar
set laststatus=2

"""" Enable Menlo font """"
let g:airline_powerline_fonts = 1

" Show PASTE if in paste mode
let g:airline_detect_paste=1

" Show airline for tabs too
let g:airline#extensions#tabline#enabled = 1

" Use the solarized theme for the Airline status bar
let g:airline_theme='solarized'

"""" Nerdtree config """"
" Open/close NERDTree Tabs with \t
nmap <silent> <leader>t :NERDTreeTabsToggle<CR>
" To have NERDTree always open on startup
let g:nerdtree_tabs_open_on_console_startup = 1

"""" Scrooloose/syntastic settings """"
let g:syntastic_error_symbol = '✘'
let g:syntastic_warning_symbol = "▲"
augroup mySyntastic
  au!
  au FileType tex let b:syntastic_mode = "passive"
augroup END

"""" Easytags settings """
set tags=./tags;,~/.vimtags
" Sensible defaults
let g:easytags_events = ['BufReadPost', 'BufWritePost']
let g:easytags_async = 1
let g:easytags_dynamic_files = 2
let g:easytags_resolve_links = 1
let g:easytags_suppress_ctags_warning = 1

"""" Tagbar settings """"
" Open/close tagbar with \b
nmap <silent> <leader>b :TagbarToggle<CR>
" Open tagbar automatically whenever possible
autocmd BufEnter * nested :call tagbar#autoopen(0)

"""" Vimgutter settings """
" In vim-airline, only display "hunks" if the diff is non-zero
let g:airline#extensions#hunks#non_zero_only = 1

"""" delimitMate settings """
let delimitMate_expand_cr = 1
augroup mydelimitMate
  au!
  au FileType markdown let b:delimitMate_nesting_quotes = ["`"]
  au FileType tex let b:delimitMate_quotes = ""
  au FileType tex let b:delimitMate_matchpairs = "(:),[:],{:},`:'"
  au FileType python let b:delimitMate_nesting_quotes = ['"', "'"]
augroup END

"""" Superman config """"
noremap K :SuperMan <cword><CR>

编辑:

vim --version的响应之下

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Nov 29 2017 18:37:46)
Included patches: 1-503, 505-680, 682-1283
Compiled by root@apple.com
Normal version without GUI.  Features included (+) or not (-):
+acl             +file_in_path    -mouse_sgr       +tag_old_static
-arabic          +find_in_path    -mouse_sysmouse  -tag_any_white
+autocmd         +float           -mouse_urxvt     -tcl
-balloon_eval    +folding         +mouse_xterm     -termguicolors
-browse          -footer          +multi_byte      -terminal
+builtin_terms   +fork()          +multi_lang      +terminfo
+byte_offset     -gettext         -mzscheme        +termresponse
+channel         -hangul_input    +netbeans_intg   +textobjects
+cindent         +iconv           +num64           +timers
-clientserver    +insert_expand   +packages        +title
-clipboard       +job             +path_extra      -toolbar
+cmdline_compl   +jumplist        -perl            +user_commands
+cmdline_hist    -keymap          +persistent_undo +vertsplit
+cmdline_info    +lambda          +postscript      +virtualedit
+comments        -langmap         +printer         +visual
-conceal         +libcall         -profile         +visualextra
+cryptv          +linebreak       +python/dyn      +viminfo
+cscope          +lispindent      -python3         +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con      -lua             -rightleft       +windows
+diff            +menu            +ruby/dyn        +writebackup
+digraphs        +mksession       +scrollbind      -X11
-dnd             +modify_fname    +signs           -xfontset
-ebcdic          +mouse           +smartindent     -xim
-emacs_tags      -mouseshape      +startuptime     -xpm
+eval            -mouse_dec       +statusline      -xsmp
+ex_extra        -mouse_gpm       -sun_workshop    -xterm_clipboard
+extra_search    -mouse_jsbterm   +syntax          -xterm_save
-farsi           -mouse_netterm   +tag_binary
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X_UNIX  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -L/usr/local/lib -o vim        -lm -lncurses  -liconv -framework Cocoa

编辑2

我现在注意到,当我尝试重新加载我的.vimrc文件时,出现以下错误:

Error detected while processing /usr/share/vim/vim80/syntax/syntax.vim:
line   42:
E216: No such group or event: filetypedetect BufRead

在改变运行时runtimepath值的方向上 ,我指出了这一点 ,但我没有在任何地方定义它。 我试过将它添加到我的.vimrc ,但重新加载后仍然出现相同的错误。

我把它放在文档的顶部(在set nocompatible ,所以也许这个位置可能是问题,但是如果是这样的话,我应该把它放在哪里呢?


I've just been busy configuring vim to look like an IDE with the help of this and this source, but i can't seem to get the syntax highlighting to work.

In my ~/.vimrc i have the following two settings filetype plugin indent on and syntax on that supposed to highlight the syntax, but whenever i open a file (Javascript for example) it doesn't work.

When i open the file and do :syntax list i get the following response: No syntax items defined for this buffer

I (quick) search on the internet al refer to the settings i mentioned (and are defined correctly).

What am i missing?

Below my whole .vimrc content

set nocompatible

"""" Config Vundle plugin manager """""
filetype off

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

Plugin 'VundleVim/Vundle.vim'

"""" Plugins """"
Plugin 'altercation/vim-colors-solarized'
Plugin 'tomasr/molokai'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'scrooloose/nerdtree'
Plugin 'jistr/vim-nerdtree-tabs'
Plugin 'vim-syntastic/syntastic'
Plugin 'xolox/vim-misc'
Plugin 'xolox/vim-easytags'
Plugin 'majutsushi/tagbar'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'vim-scripts/a.vim'
Plugin 'airblade/vim-gitgutter'
Plugin 'tpope/vim-fugitive'
Plugin 'Raimondi/delimitMate'
Plugin 'jez/vim-superman'
Plugin 'christoomey/vim-tmux-navigator'
Plugin 'jez/vim-c0'
Plugin 'jez/vim-ispc'
Plugin 'kchmck/vim-coffee-script'
Plugin 'godlygeek/tabular'
Plugin 'HTML-AutoCloseTag'
Plugin 'ekalinin/Dockerfile.vim'
Plugin 'cakebaker/scss-syntax.vim'
Plugin 'tpope/vim-surround'
Plugin 'ntpeters/vim-better-whitespace'
Plugin 'edkolev/tmuxline.vim'

"""" OSX stupid backspace fix """"
set backspace=indent,eol,start

call vundle#end()
filetype plugin indent on
syntax on

"""" General settings """"
set backspace=indent,eol,start
set ruler
set number
set showcmd
set incsearch
set hlsearch

"""" Set tabs """"
set tabstop=2
set shiftwidth=2
set smarttab
set expandtab

"""" Enable mouse support """"
set mouse=a

"""" Enable highlighting of the current line """"
set cursorline

"""" Support symbols in the title bar """"
hi clear SignColumn

"""" Colorscheme (Solarized) """"
set background=dark
colorscheme solarized

" Always show statusbar
set laststatus=2

"""" Enable Menlo font """"
let g:airline_powerline_fonts = 1

" Show PASTE if in paste mode
let g:airline_detect_paste=1

" Show airline for tabs too
let g:airline#extensions#tabline#enabled = 1

" Use the solarized theme for the Airline status bar
let g:airline_theme='solarized'

"""" Nerdtree config """"
" Open/close NERDTree Tabs with \t
nmap <silent> <leader>t :NERDTreeTabsToggle<CR>
" To have NERDTree always open on startup
let g:nerdtree_tabs_open_on_console_startup = 1

"""" Scrooloose/syntastic settings """"
let g:syntastic_error_symbol = '✘'
let g:syntastic_warning_symbol = "▲"
augroup mySyntastic
  au!
  au FileType tex let b:syntastic_mode = "passive"
augroup END

"""" Easytags settings """
set tags=./tags;,~/.vimtags
" Sensible defaults
let g:easytags_events = ['BufReadPost', 'BufWritePost']
let g:easytags_async = 1
let g:easytags_dynamic_files = 2
let g:easytags_resolve_links = 1
let g:easytags_suppress_ctags_warning = 1

"""" Tagbar settings """"
" Open/close tagbar with \b
nmap <silent> <leader>b :TagbarToggle<CR>
" Open tagbar automatically whenever possible
autocmd BufEnter * nested :call tagbar#autoopen(0)

"""" Vimgutter settings """
" In vim-airline, only display "hunks" if the diff is non-zero
let g:airline#extensions#hunks#non_zero_only = 1

"""" delimitMate settings """
let delimitMate_expand_cr = 1
augroup mydelimitMate
  au!
  au FileType markdown let b:delimitMate_nesting_quotes = ["`"]
  au FileType tex let b:delimitMate_quotes = ""
  au FileType tex let b:delimitMate_matchpairs = "(:),[:],{:},`:'"
  au FileType python let b:delimitMate_nesting_quotes = ['"', "'"]
augroup END

"""" Superman config """"
noremap K :SuperMan <cword><CR>

EDIT:

Below the response of vim --version

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Nov 29 2017 18:37:46)
Included patches: 1-503, 505-680, 682-1283
Compiled by root@apple.com
Normal version without GUI.  Features included (+) or not (-):
+acl             +file_in_path    -mouse_sgr       +tag_old_static
-arabic          +find_in_path    -mouse_sysmouse  -tag_any_white
+autocmd         +float           -mouse_urxvt     -tcl
-balloon_eval    +folding         +mouse_xterm     -termguicolors
-browse          -footer          +multi_byte      -terminal
+builtin_terms   +fork()          +multi_lang      +terminfo
+byte_offset     -gettext         -mzscheme        +termresponse
+channel         -hangul_input    +netbeans_intg   +textobjects
+cindent         +iconv           +num64           +timers
-clientserver    +insert_expand   +packages        +title
-clipboard       +job             +path_extra      -toolbar
+cmdline_compl   +jumplist        -perl            +user_commands
+cmdline_hist    -keymap          +persistent_undo +vertsplit
+cmdline_info    +lambda          +postscript      +virtualedit
+comments        -langmap         +printer         +visual
-conceal         +libcall         -profile         +visualextra
+cryptv          +linebreak       +python/dyn      +viminfo
+cscope          +lispindent      -python3         +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con      -lua             -rightleft       +windows
+diff            +menu            +ruby/dyn        +writebackup
+digraphs        +mksession       +scrollbind      -X11
-dnd             +modify_fname    +signs           -xfontset
-ebcdic          +mouse           +smartindent     -xim
-emacs_tags      -mouseshape      +startuptime     -xpm
+eval            -mouse_dec       +statusline      -xsmp
+ex_extra        -mouse_gpm       -sun_workshop    -xterm_clipboard
+extra_search    -mouse_jsbterm   +syntax          -xterm_save
-farsi           -mouse_netterm   +tag_binary
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X_UNIX  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -L/usr/local/lib -o vim        -lm -lncurses  -liconv -framework Cocoa

EDIT 2

I now noticed that when i try to reload my .vimrc file, i get the following error:

Error detected while processing /usr/share/vim/vim80/syntax/syntax.vim:
line   42:
E216: No such group or event: filetypedetect BufRead

Which points me in the direction of changing my runtimepath value, but i don't have that defined anywhere. I've tried adding it to my .vimrc, but i still get the same error after reloading.

I've placed it at the top of the document (right after set nocompatible, so perhaps the position could be the issue, but if so, where should i place it then?


原文:https://stackoverflow.com/questions/49708824
更新时间:2022-03-18 16:03

最满意答案

freemarker没有功能。freemarker要求你自己把东西取出来放到request的attribute里面,然后在ftl文件中使用那些attribute。

可以自己用Java反射来得到实体中字段,然后自己拼html字符串

其他回答

可以的,我说说大概思路,很简单,你自己具体实现吧,把代码写给你没意义的:
1.将你这段字符串输出到一个文件里,用java类文件的方式命名。
2.调用外部javac命令将该文件编译。
3.用类加载器(classload)动态加载新的class文件并用class.forname()注册该类,然后就可以正常使用了。
上面的每一步都能在baidu中找到实现方法,自己发挥吧。
不了解你的意思,我把注解理解成标识,在一个方法中调用解析,生成html(这个html是要在哪用?这是在自定义jsp标签么?)select多条数据
你要做成什么样子?

相关问答

更多
  • File f_html = new File("Login.html"); f_html.createNewFile(); 打字不易,如满意,望采纳。
  • 确实是这样,每次留言后自动生成一次html,留言一般都有分页,所以自动生成,并不浪费什么性能。
  • 因为配置文件提供了mybatis-generator所需要的参数信息:*其中classPathEntry是引用的jdbc的类路径,这里将jdbcjar和generator的jar包放在一起了;*commentGenerator是用来除去时间信息的,这在配合类似subversion的代码管理工具时使用很有效,因为可以减少没有必要的注释迁入;*jdbcConnection是指定的jdbc的连接信息;*javaTypeResolver式类型转换的信息,这里并没有用到;*javaModelGenerator是模型的 ...
  • freemarker没有功能。freemarker要求你自己把东西取出来放到request的attribute里面,然后在ftl文件中使用那些attribute。 可以自己用Java反射来得到实体中字段,然后自己拼html字符串
  • 使用Delphi TPageProducer。 它从“接近HTML”模板生成HTML,其中包含特殊的tage。 您在事件中回应这些标签并将其替换为您自己的数据。 作品一种享受。 Use the Delphi TPageProducer. It generates HTML from a 'close to HTML' template which contains special tage. You respond to these tag in an event and replace them with ...
  • 由于这似乎不可能以我希望/想到的方式,我改为在PHP中编写代码来收集并将生成的表单详细信息存储在数据库中。 然后,当用户返回到表单时,我检查他们的user_id是否在搜索历史记录表中,如果是,请使用PHP将表单构建回他们拥有它的方式。 提交表单时的代码: foreach($_POST["where_field"] as $key => $val){ $stmt = $pdo->prepare('INSERT INTO dynamic_form (user_id, where_field, where ...
  • 看看代码模型 ,用于我的项目成功。 Have a look at codemodel, used with success for my projects.
  • 您可以使用称为“输出缓冲”的技术。 # start redirecting output to a buffer ob_start(); # execute the other PHP file include('myfile.php'); # grab whatever got output since ob_start() (and stop buffering) $html = ob_get_clean(); You can use the technique called "output bu ...
  • 尽管我喜欢XSLT,但我认为它可能有点沉重。 Freemarker是为这种东西而制作的。 它可以在html中使用带有$ {name}等参数的HTML模板,并创建输出而不依赖于jsp。 As much as I like XSLT, I think it may be a bit heavy for this purpose. Freemarker is made for this kind of thing. It can take an HTML template with parameters like ...
  • 您可以创建一个为您生成源代的ant构建文件。 然后您可以自由使用您喜欢的任何代码生成器。 Ant支持是eclipse IDE的一部分。 如果您更喜欢maven,那么可以使用一个很好的eclipse插件(这就是我实际使用的基于jaxb,javacc和xdoclet的源代码生成...)。 从技术角度讲,你只需添加另一个eclipse构建器,该构建器在eclipse检测到代码库中的变化时随时调用。 如果你已经有了一个代码生成器,只要有一个插件可用就'问'互联网。 编辑 关于如何安装构建器:这是自动完成的。 对于m ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)