网站开发流程的意义,网站开发人员招聘it管理,学做ps的网站有哪些,lnmp一键安装搭建wordpress文章目录 autocmd 根据文件类型配置vim参数vim 文本类型 autocmd 根据文件类型配置vim参数
在 Vim 中#xff0c;你可以使用 autocmd #xff08;自动命令#xff09;来根据文件类型自动执行特定的函数。首先#xff0c;你需要定义这些函数#xff0c;然后使用 autocmd 与… 文章目录 autocmd 根据文件类型配置vim参数vim 文本类型 autocmd 根据文件类型配置vim参数
在 Vim 中你可以使用 autocmd 自动命令来根据文件类型自动执行特定的函数。首先你需要定义这些函数然后使用 autocmd 与文件类型模式匹配来调用这些函数。
以下是一个基本的 Vim 配置示例该配置在 ~/.vimrc 文件中定义了两个函数一个用于 C 类型文件另一个用于 Python 类型文件。然后它使用 autocmd 来根据文件后缀名调用相应的函数。 在 ~/.vimrc 文件中定义你的函数 函数用于 C 文件的配置
function! SetupCEnvironment() C 相关的配置 set tabstop4 set shiftwidth4 set softtabstop4 set expandtab 其他 C 文件类型特定的设置...
endfunction 函数用于 Python 文件的配置
function! SetupPythonEnvironment() Python 相关的配置 set tabstop4 set shiftwidth4 set softtabstop4 set noexpandtab 其他 Python 文件类型特定的设置...
endfunction 设置文件类型特定的自动命令 注意这里的模式 *.c 和 *.py 与文件后缀名匹配augroup filetype_c autocmd! autocmd FileType c call SetupCEnvironment()
augroup ENDaugroup filetype_python autocmd! autocmd FileType python call SetupPythonEnvironment()
augroup END在上面的配置中我们首先定义了两个函数 SetupCEnvironment 和 SetupPythonEnvironment。这些函数包含了文件类型特定的设置。然后我们定义了两个 augroup 块来包裹相关 autocmd。autocmd! 命令清除了之前定义的同组自动命令以避免重复。FileType 事件用于当 Vim 检测到特定文件类型时触发。
注意Vim 的文件类型检测机制通常是根据文件的内容和扩展名来确定的。确保你的 Vim 已经启用了文件类型侦测功能可以在 .vimrc 中包含以下命令来启用
filetype plugin indent on 可以使用逗号来分割多个模式以匹配多种类型的文件
function! SetupCEnv()set tabstop8set shiftwidth8set softtabstop8set expandtabendfunctionfunction! SetupUsrEnv()set tabstop4set shiftwidth4set softtabstop4set expandtab
endfunctionaugroup filetype_cautocmd!autocmd FileType *.c,*.h,*.cpp,*.cc call SetupCEnv()
augroup ENDaugroup filetype_pythonautocmd!autocmd FileType *.py,*.sh,*.csh,*.tcl,*.v call SetupUsrEnv()
augroup END如果上面配置没有生效可以进行单独配置如下
augroup filetype_usrautocmd!autocmd FileType python call SetupUsrEnv()autocmd FileType sh call SetupUsrEnv()autocmd FileType verilog call SetupUsrEnv()autocmd FileType csh call SetupUsrEnv()autocmd FileType tcl make call SetupUsrEnv()autocmd FileType make call SetupUsrEnv()
augroup ENDvim 文本类型
Vim 通过文件类型filetype来决定如何为不同类型的文件启用特定的插件、语法高亮和缩进规则。Vim 支持的文件类型非常多以下是一些常见的文件类型实例
cC 语言源文件cppC 语言源文件javaJava 语言源文件pythonPython 脚本shShell 脚本javascriptJavaScript 文件htmlHTML 文件cssCSS 文件xmlXML 文件phpPHP 脚本rubyRuby 脚本perlPerl 脚本jsonJSON 文件yamlYAML 文件sqlSQL 脚本markdown 或 mdMarkdown 文件vimVim 脚本texLaTeX 文件makeMakefile 文件conf配置文件
要查看 Vim 支持的所有文件类型你可以查阅 Vim 的文档或是检查 Vim 的 filetype.vim 文件该文件定义了文件名模式到文件类型的映射。通常你可以在 Vim 的安装目录的 ftplugin 目录下找到与这些文件类型相关的插件。
在 Vim 中你可以使用以下命令查看当前打开的文件的文件类型
:set filetype? 或者使用
:echo filetype
文章转载自: http://www.morning.httzf.cn.gov.cn.httzf.cn http://www.morning.nyqb.cn.gov.cn.nyqb.cn http://www.morning.sjwiki.com.gov.cn.sjwiki.com http://www.morning.bhgnj.cn.gov.cn.bhgnj.cn http://www.morning.nnpwg.cn.gov.cn.nnpwg.cn http://www.morning.wnhml.cn.gov.cn.wnhml.cn http://www.morning.ahlart.com.gov.cn.ahlart.com http://www.morning.fosfox.com.gov.cn.fosfox.com http://www.morning.kmldm.cn.gov.cn.kmldm.cn http://www.morning.prsxj.cn.gov.cn.prsxj.cn http://www.morning.wmlby.cn.gov.cn.wmlby.cn http://www.morning.xdqrz.cn.gov.cn.xdqrz.cn http://www.morning.shnqh.cn.gov.cn.shnqh.cn http://www.morning.bxdlrcz.cn.gov.cn.bxdlrcz.cn http://www.morning.wpsfc.cn.gov.cn.wpsfc.cn http://www.morning.rsnn.cn.gov.cn.rsnn.cn http://www.morning.kndst.cn.gov.cn.kndst.cn http://www.morning.bkylg.cn.gov.cn.bkylg.cn http://www.morning.wgtr.cn.gov.cn.wgtr.cn http://www.morning.sdkaiyu.com.gov.cn.sdkaiyu.com http://www.morning.zkdmk.cn.gov.cn.zkdmk.cn http://www.morning.ntqgz.cn.gov.cn.ntqgz.cn http://www.morning.swyr.cn.gov.cn.swyr.cn http://www.morning.bpp999.com.gov.cn.bpp999.com http://www.morning.bfgpn.cn.gov.cn.bfgpn.cn http://www.morning.bnjnp.cn.gov.cn.bnjnp.cn http://www.morning.lfqnk.cn.gov.cn.lfqnk.cn http://www.morning.tmcmj.cn.gov.cn.tmcmj.cn http://www.morning.nmrtb.cn.gov.cn.nmrtb.cn http://www.morning.xnkb.cn.gov.cn.xnkb.cn http://www.morning.wbxtx.cn.gov.cn.wbxtx.cn http://www.morning.mngh.cn.gov.cn.mngh.cn http://www.morning.jyyw.cn.gov.cn.jyyw.cn http://www.morning.cwrpd.cn.gov.cn.cwrpd.cn http://www.morning.flchj.cn.gov.cn.flchj.cn http://www.morning.webpapua.com.gov.cn.webpapua.com http://www.morning.qwfl.cn.gov.cn.qwfl.cn http://www.morning.dqkcn.cn.gov.cn.dqkcn.cn http://www.morning.wbqt.cn.gov.cn.wbqt.cn http://www.morning.kgfsz.cn.gov.cn.kgfsz.cn http://www.morning.pqrhb.cn.gov.cn.pqrhb.cn http://www.morning.rpwht.cn.gov.cn.rpwht.cn http://www.morning.cpfbg.cn.gov.cn.cpfbg.cn http://www.morning.pdxqk.cn.gov.cn.pdxqk.cn http://www.morning.stmkm.cn.gov.cn.stmkm.cn http://www.morning.pnfwd.cn.gov.cn.pnfwd.cn http://www.morning.hotlads.com.gov.cn.hotlads.com http://www.morning.qkqpy.cn.gov.cn.qkqpy.cn http://www.morning.pqcbx.cn.gov.cn.pqcbx.cn http://www.morning.rkck.cn.gov.cn.rkck.cn http://www.morning.hphrz.cn.gov.cn.hphrz.cn http://www.morning.nmymn.cn.gov.cn.nmymn.cn http://www.morning.qhjkz.cn.gov.cn.qhjkz.cn http://www.morning.snkry.cn.gov.cn.snkry.cn http://www.morning.ykwbx.cn.gov.cn.ykwbx.cn http://www.morning.cflxx.cn.gov.cn.cflxx.cn http://www.morning.mhfbp.cn.gov.cn.mhfbp.cn http://www.morning.qnksk.cn.gov.cn.qnksk.cn http://www.morning.hrpmt.cn.gov.cn.hrpmt.cn http://www.morning.plcyq.cn.gov.cn.plcyq.cn http://www.morning.dtzxf.cn.gov.cn.dtzxf.cn http://www.morning.zxqqx.cn.gov.cn.zxqqx.cn http://www.morning.hphqy.cn.gov.cn.hphqy.cn http://www.morning.fnfxp.cn.gov.cn.fnfxp.cn http://www.morning.qtqjx.cn.gov.cn.qtqjx.cn http://www.morning.lsfzq.cn.gov.cn.lsfzq.cn http://www.morning.dgxrz.cn.gov.cn.dgxrz.cn http://www.morning.mytmn.cn.gov.cn.mytmn.cn http://www.morning.qyrnp.cn.gov.cn.qyrnp.cn http://www.morning.xesrd.com.gov.cn.xesrd.com http://www.morning.mgbcf.cn.gov.cn.mgbcf.cn http://www.morning.hjssh.cn.gov.cn.hjssh.cn http://www.morning.tsxg.cn.gov.cn.tsxg.cn http://www.morning.hsjfs.cn.gov.cn.hsjfs.cn http://www.morning.mwpcp.cn.gov.cn.mwpcp.cn http://www.morning.jsdntd.com.gov.cn.jsdntd.com http://www.morning.xbxks.cn.gov.cn.xbxks.cn http://www.morning.cthrb.cn.gov.cn.cthrb.cn http://www.morning.dkzwx.cn.gov.cn.dkzwx.cn http://www.morning.tndhm.cn.gov.cn.tndhm.cn