vim编辑Dockerfile时语法高亮
三个文件扔进相关的目录即可
1. /usr/share/vim/vimfiles/doc/dockerfile.txt
*dockerfile.txt* Syntax highlighting for Dockerfiles
Author: Honza Pokorny <https://honza.ca>
License: BSD
INSTALLATION *installation*
Drop it on your Pathogen path and you're all set.
FEATURES *features*
The syntax highlighting includes:
* The directives (e.g. FROM)
* Strings
* Comments
vim:tw=78:et:ft=help:norl:
2. /usr/share/vim/vimfiles/ftdetect/dockerfile.vim
au BufNewFile,BufRead [Dd]ockerfile,Dockerfile.*,*.Dockerfile set filetype=dockerfile
3. /usr/share/vim/vimfiles/syntax/dockerfile.vim
" dockerfile.vim - Syntax highlighting for Dockerfiles
" Maintainer: Honza Pokorny <https://honza.ca>
" Version: 0.5
if exists("b:current_syntax")
finish
endif
let b:current_syntax = "dockerfile"
syntax case ignore
syntax match dockerfileKeyword /\v^\s*(ONBUILD\s+)?(ADD|ARG|CMD|COPY|ENTRYPOINT|ENV|EXPOSE|FROM|HEALTHCHECK|LABEL|MAINTAINER|RUN|SHELL|STOPSIGNAL|USER|VOLUME|WORKDIR)\s/
highlight link dockerfileKeyword Keyword
syntax region dockerfileString start=/\v"/ skip=/\v\\./ end=/\v"/
highlight link dockerfileString String
syntax match dockerfileComment "\v^\s*#.*$"
highlight link dockerfileComment Comment
set commentstring=#\ %s
" match "RUN", "CMD", and "ENTRYPOINT" lines, and parse them as shell
let s:current_syntax = b:current_syntax
unlet b:current_syntax
syntax include @SH syntax/sh.vim
let b:current_syntax = s:current_syntax
syntax region shLine matchgroup=dockerfileKeyword start=/\v^\s*(RUN|CMD|ENTRYPOINT)\s/ end=/\v$/ contains=@SH
" since @SH will handle "\" as part of the same line automatically, this "just works" for line continuation too, but with the caveat that it will highlight "RUN echo '" followed by a newline as if it were a block because the "'" is shell line continuation... not sure how to fix that just yet (TODO)
效果展示
附录
vim编辑Dockerfile时语法高亮的更多相关文章
- Ubuntu vim显示行号语法高亮自动缩进
配置文件名为Ubuntu vimrc在Fedora中vim的配置文件存放在/etc目录中,配置文件名为Ubuntu vimrc在终端 输入以下命令来编辑Ubuntu vimrc配置文件:sudo vi ...
- vim 支持 nginx配置文件 语法高亮
1.下载 nginx.vim 语法高亮文件 2.将文件复制到 /usr/share/vim/vim74/syntax 目录(也可以是 单用户目录 ~/.vim/syntax/) 3.修改 vim /u ...
- vim编辑文件时[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:
出现这个问题是因为你上次编辑的时候在没有保存的情况下退出了(如:电脑关机等)也有可能是有其他人在和你同时进行编辑行为(不同会话中).这是因为在用vim编辑的时候,vim会在打开文件目录下 ...
- Vim 编辑文件时,突然断开链接
centos 系统 编辑文本 突然退出 ,恢复文档操作: 有道笔记链接地址
- 解决securecrt连接centos使用VIM编辑中文时乱码
vim ~/.vimrc 添加两行 set encoding=utf-8 set fileencodings=ucs-bom,utf-8,cp936
- linux 磁盘满了,vim 编辑文件时无法保存
早上来发现 redis 不能用,报 MISCONF Redis is configured to save RDB snapshots, but it is currently not able to ...
- Linux vim编写程序时出现高亮字符,如何取消?
在“命令模式”下输入“:nohl“,再按回车,便可以取消高亮显示.
- vim编辑makefile时临时不展开tab为空格
可以先敲ctrl-v组合键,再敲tab键,这样就不会被转换成空格了. 给自己的备忘!
- linux vim 编辑文件时无法保存
操作ESC + : wq 无反应 那么我们操作SHFT按键,在操作Z按键,连续按两下Z按键即可(保存当前内容且退出)
随机推荐
- hdu 1796 How many integers can you find 容斥第一题
How many integers can you find Time Limit: 12000/5000 MS (Java/Others) Memory Limit: 65536/32768 ...
- [CF912D]Fishes - 求数学期望,乱搞
D. Fishes time limit per test 1 second memory limit per test 256 megabytes input standard input outp ...
- ZOJ-3777-Problem Arrangement(状压DP)
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3777 题意: 输入n和m,接下来一个n*n的矩阵,a[i][j]表示第i道 ...
- BatchNormalization、LayerNormalization、InstanceNorm、GroupNorm、SwitchableNorm总结
https://blog.csdn.net/liuxiao214/article/details/81037416 http://www.dataguru.cn/article-13032-1.htm ...
- 实现图像添加label
void CmapwingisTest2View::OnToolsAddTiffLayer() { TCHAR szFilters[]= _T("TIFF Files (*.tif)|*.t ...
- gulp自动化构建工具安装使用(1)
我用的是windows,所以以下操作针对于windows用户,其他系统有不一样的地方请自行查阅资料更正. 好了,废话少说,反正也就是随手捣腾.下雨了,天晴了,我们开始搞gulp了 安装:gulp是个构 ...
- CentOS 7下载
CentOS 7官方下载地址:https://www.centos.org/download/ 转载https://blog.csdn.net/yxwmzouzou/article/details/7 ...
- RN的win7开发环境部署和问题解决
1安装node,配置环境变量 2.安装Android studioe,配置环境变量 3.安装python2 注意 Node 的版本必须高于 8.3,Python 的版本必须为 2.x(不支持 3.x) ...
- PowerBuilder -- 连接sqlite
1.注册表修改,将以下内容保存为.reg文件,然后双击执行,注:测试机器为win10 64位系统 Windows Registry Editor Version 5.00 [HKEY_LOCAL_MA ...
- template要加s,重启服务,不然报错