vim中的语法高亮显示不起作用(Syntax highlight in vim not working at all)
我刚刚在这个和这个源代码的帮助下忙着配置vim看起来像一个IDE,但我似乎无法让语法突出显示工作。
在我的
~/.vimrc
我有以下两个设置filetype plugin indent on
和syntax 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 settingsfiletype plugin indent on
andsyntax 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
contentset 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
最满意答案
freemarker没有功能。freemarker要求你自己把东西取出来放到request的attribute里面,然后在ftl文件中使用那些attribute。 可以自己用Java反射来得到实体中字段,然后自己拼html字符串
其他回答
可以的,我说说大概思路,很简单,你自己具体实现吧,把代码写给你没意义的: 1.将你这段字符串输出到一个文件里,用java类文件的方式命名。 2.调用外部javac命令将该文件编译。 3.用类加载器(classload)动态加载新的class文件并用class.forname()注册该类,然后就可以正常使用了。 上面的每一步都能在baidu中找到实现方法,自己发挥吧。
不了解你的意思,我把注解理解成标识,在一个方法中调用解析,生成html(这个html是要在哪用?这是在自定义jsp标签么?)select多条数据 你要做成什么样子?
相关问答
更多-
如何用java生成html文件?[2021-08-05]
File f_html = new File("Login.html"); f_html.createNewFile(); 打字不易,如满意,望采纳。 -
JAVA CMS系统生成HTML文件?[2021-10-09]
确实是这样,每次留言后自动生成一次html,留言一般都有分页,所以自动生成,并不浪费什么性能。 -
generator怎么生成html代码[2022-02-18]
因为配置文件提供了mybatis-generator所需要的参数信息:*其中classPathEntry是引用的jdbc的类路径,这里将jdbcjar和generator的jar包放在一起了;*commentGenerator是用来除去时间信息的,这在配合类似subversion的代码管理工具时使用很有效,因为可以减少没有必要的注释迁入;*jdbcConnection是指定的jdbc的连接信息;*javaTypeResolver式类型转换的信息,这里并没有用到;*javaModelGenerator是模型的 ... -
JAVA动态生成HTML代码[2023-05-16]
freemarker没有功能。freemarker要求你自己把东西取出来放到request的attribute里面,然后在ftl文件中使用那些attribute。 可以自己用Java反射来得到实体中字段,然后自己拼html字符串 -
生成动态html(Generate dynamic html)[2022-11-04]
使用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 ...
-
Java代码生成(Java code generation)[2021-06-24]
看看代码模型 ,用于我的项目成功。 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 ...
-
用Java创建动态生成代码的工具(在Eclipse中)(Tool for creating Dynamically Generated Code in Java (In Eclipse))[2022-02-19]
您可以创建一个为您生成源代的ant构建文件。 然后您可以自由使用您喜欢的任何代码生成器。 Ant支持是eclipse IDE的一部分。 如果您更喜欢maven,那么可以使用一个很好的eclipse插件(这就是我实际使用的基于jaxb,javacc和xdoclet的源代码生成...)。 从技术角度讲,你只需添加另一个eclipse构建器,该构建器在eclipse检测到代码库中的变化时随时调用。 如果你已经有了一个代码生成器,只要有一个插件可用就'问'互联网。 编辑 关于如何安装构建器:这是自动完成的。 对于m ...