从一开始,有多少行必须放置各种方向? [英] Within how many lines from the beginning do various directions have to be placed?

查看:138
本文介绍了从一开始,有多少行必须放置各种方向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个特定方式解释的注释字符有各种方向。

There are various directions following a comment character # that are interpreted in a specific way.


  • UNIX shebang:#!/ usr / bin / env ruby​​

  • 编码的魔术注释(用于Ruby 1.9 ): #coding:UTF-8

  • 冻结字符串字面值pragma: #frozen_string_literal:true

  • 文本编辑器的ruby-mode方向(如emacs):#!ruby

  • vim编码方向: #vim:set fileencoding = euc-jp

  • UNIX shebang: #!/usr/bin/env ruby
  • magic comment for encoding (used in Ruby 1.9): #coding: UTF-8
  • frozen string literal pragma: #frozen_string_literal: true
  • ruby-mode direction for text editors (like emacs): #!ruby
  • vim encoding direction: #vim:set fileencoding=euc-jp

很明显,它们必须放置在文件开头附近才能正常工作,但是当有多个文件不能全部放在第一行时。在文件开头有多少行,它们必须被放置?它们之间的相对顺序是否相关?有什么规则来决定他们?

It is clear that they have to be placed near the beginning of the file to work correctly, but when there are more than one of them, they cannot all be placed on the first line. Within how many lines from the beginning of the file do they have to be placed? Is the relative order between them relevant? What are the rules that decide them?

如果有上面列出的其他内容,请添加。

If there are other than those I listed above, please add that.

推荐答案

(这是一个社区维基答案,不完整,请添加您的发现。)


  • UNIX shebang

  • 必须出现在shell脚本第一行的左边距上

  • 由内核解释,一些文本编辑器使用它来确定文件类型


  • 编码的魔术注释

  • 必须出现在第一行或第二行,如果第一行是shebang,但可以格式化松散,例如# - * - 编码:utf-8 - * -

  • 解释为Ruby 1.9 +



  • 解释为Ruby 2.3


  • Emacs文件局部变量

  • 必须出现在第一行或第二行,如果第一行是shebang

  • 解释为Emacs


  • Vim modeline

  • 必须出现在前5行或最后5行,尽管此数字可以使用 modelines 设置

  • 如果启用了 modeline 设置,则由Vim解释默认除)。

  • Vim modeline
  • Must appear within the first five or last five lines, although this number is configurable with the modelines setting
  • Interpreted by Vim if the modeline setting is enabled (on by default except for root).

这篇关于从一开始,有多少行必须放置各种方向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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