告诉VI用软选项卡和指定的缩进来读/写源文件的语法是什么? [英] what's the syntax for telling VI to read/write a source file with soft-tabs and a specified indentation?

查看:113
本文介绍了告诉VI用软选项卡和指定的缩进来读/写源文件的语法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Someplace我看到一段代码,告诉vi使用软标签并设置选项卡的大小。如果你将这个片段放在源文件的底部,那么vi将会神奇地使用这些文件的设置。

Someplace I saw a snippet of code which told vi to use soft tabs and set the size of a tab. If you put this snippet at the bottom of a source file, then vi would magically use those settings for that file.

将该片段包含在哪里的语法和规则是什么?源文件?可以使用这些设置吗?

What is the syntax and rules for including that snippet in a source file? Can emacs be made to use these settings as well?

推荐答案

您可以将其放在源文件中的评论中: p>

You can put this in a comment in your source file:

ex: set softtabstop=4 shiftwidth=4 tabstop=4 expandtab: 

注释语法取决于源文件的类型。

The comment syntax depends on the type of the source file.

对于C / C ++ / Java,将是:

For C/C++/Java, this would be:

// ex: set softtabstop=4 shiftwidth=4 tabstop=4 expandtab: 

对于JSP,这将是:

<%-- ex: set softtabstop=4 shiftwidth=4 tabstop=4 expandtab: --%>

如果它放在源文件的开头,这可以工作,但我不确定如果放在最后也可以工作。

This works if it is placed at the beginning of the source file, but I'm not sure that this'll work if placed at the end of it too.

这不适用于emacs。对于emacs可能有不同的方法来实现。

This will not work for emacs. There might be a different way of achieving the same for emacs.

这篇关于告诉VI用软选项卡和指定的缩进来读/写源文件的语法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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