Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为Vim'添加一个钩子;默认缓冲区_Vim - Fatal编程技术网

为Vim'添加一个钩子;默认缓冲区

为Vim'添加一个钩子;默认缓冲区,vim,Vim,我想配置Vim,以便当[No Name]缓冲区打开时,语法设置为markdown。这可能吗?在维姆的帮助下,我看不到这样的诱惑 我使用的是Vim 7.3,它是用--with features=ground编译的,这里提到: “默认文件类型 设g:do_filetype=0 au GUIEnter,BufAdd*if expand(“”)=“”|让g:do_filetype=1 | endif au BufEnter*如果g:do_文件类型| setf markdown |让g:do_文件类型=0

我想配置Vim,以便当[No Name]缓冲区打开时,语法设置为markdown。这可能吗?在维姆的帮助下,我看不到这样的诱惑

我使用的是Vim 7.3,它是用
--with features=ground

编译的,这里提到:

“默认文件类型
设g:do_filetype=0
au GUIEnter,BufAdd*if expand(“”)=“”|让g:do_filetype=1 | endif
au BufEnter*如果g:do_文件类型| setf markdown |让g:do_文件类型=0 | endif
我的理解是,为什么需要使用全局变量,而不是立即设置文件类型,因为触发autocmd时缓冲区尚未完全创建


谢谢!这适用于gui。我将GUIEnter改为BufWenter,使其在终端中工作。
" default filetype
let g:do_filetype = 0
au GUIEnter,BufAdd * if expand('<afile>') == "" | let g:do_filetype = 1 | endif
au BufEnter * if g:do_filetype | setf markdown | let g:do_filetype = 0 | endif