VIM:为每个新文件设置filetype = txt [无名称] [英] VIM: set filetype=txt for every new file [No Name]

查看:142
本文介绍了VIM:为每个新文件设置filetype = txt [无名称]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了所有可能的方法,让vim将我创建的所有新文件的文件类型设置为"txt"(在新选项卡中),但是它不起作用.

I tried all possible things to let vim set filetype to 'txt' to all new files I create (in a new tab) but it doesn't work.

这是p.e.我在网上读过几次的书:
au BufRead,BufNewFile *.txt setlocal ft=txt
(放入_vimrc)
但是它不起作用.

This is p.e. what I've read on the web a few times:
au BufRead,BufNewFile *.txt setlocal ft=txt
(to put in _vimrc)
However it doesn't work.

有人可以帮助我吗?

推荐答案

添加到您的.vimrc中的以下行将把filetype设置为text(如果尚未设置).

The following line, added to your .vimrc, will set the filetype to text if it is not already set.

autocmd BufEnter * if &filetype == "" | setlocal ft=text | endif

这篇关于VIM:为每个新文件设置filetype = txt [无名称]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆