Deprecated: Creation of dynamic property c2c_AddAdminCSS::$admin_options_name is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 106 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$config is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 106 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$disable_contextual_help is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 106 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$disable_update_check is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 106 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$hook_prefix is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 106 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$form_name is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 106 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$menu_name is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 106 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$name is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 106 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$nonce_field is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 106 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$settings_page is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 106 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$show_admin is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 106 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$textdomain is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 106 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$textdomain_subdir is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 106 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$author_prefix is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 109 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$id_base is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 110 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$options_page is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 111 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$plugin_basename is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 112 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$plugin_file is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 113 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$plugin_path is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 114 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$u_id_base is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 115 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$version is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 116 Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php:106) in /var/www/html/wp-includes/rest-api/class-wp-rest-server.php on line 1768 {"id":52,"date":"2021-09-21T11:59:55","date_gmt":"2021-09-21T04:59:55","guid":{"rendered":"https:\/\/erwin.co\/?p=52"},"modified":"2021-09-21T11:59:55","modified_gmt":"2021-09-21T04:59:55","slug":"vim-one-line-file-headers-and-footers","status":"publish","type":"post","link":"https:\/\/erwin.co\/vim-one-line-file-headers-and-footers\/","title":{"rendered":"Vim one line file headers and footers"},"content":{"rendered":"\n
For more than 20 years I've been coming across files that have a headers or footers like:<\/p>\n\n\n\n
$OpenBSD: sshd_config.5,v 1.45 2005\/09\/21 23:36:54 djm Exp$\n\n\/* vim: set ts=8 sw=4 tw=0 noet : *\/<\/code><\/pre>\n\n\n\nYet I've never found exactly where\/how either of these tags are generated... Perhaps it just never got my attention enough. Well, all of that changes now.<\/p>\n\n\n\n
The rcs<\/code> (GNU RCS revision control system<\/a>) first released in 1991, includes a command called ident<\/code>. The ident<\/code> command manual page starts:<\/p>\n\n\n\nNAME\r\n ident - identify RCS keyword strings in files\r\n\r\nSYNOPSIS\r\n ident [ -q ] [ -V ] [ file ... ]\r\n\r\nDESCRIPTION\r\n ident searches for all instances of the pattern $keyword: text $ in the named files or, if no files are named,\r the standard input.\r\n<\/code><\/pre>\n\n\n\nNot many people use rcs<\/code> these days, but it's also possible to do this with other version managers. The key is to know that a \"$...$\" string is called an \"Ident String<\/em>\".<\/p>\n\n\n\n#include <stdio.h>\r\nstatic char const rcsid[] =\r\n \"$Id: f.c,v 5.4 1993\/11\/09 17:40:15 eggert Exp $\";\r\nint main() { return printf(\"%s\\n\", rcsid) == EOF; }\r<\/code><\/pre>\n\n\n\nIf you want to setup ident strings<\/code> with git<\/code>, you can use:<\/p>\n\n\n\n$ echo '*.txt ident' >> .gitattributes\n$ echo '$Id$' > test.txt\n$ git commit -a -m \"test\"\n\n$ rm test.txt\n$ git checkout -- test.txt\n$ cat test.txt<\/code><\/pre>\n\n\n\nNote that before 2020, the default capability of \"$ident$\" strings in git was quite limited. Fortunately, \"filters\" have been extended to provide a lot more information, so you should be replicate ident<\/code> in git<\/code> now.<\/p>\n\n\n\nSee this helpful note on Stack Overflow<\/a> summarizing the 2020 git ident<\/code> related changes.<\/p>\n\n\n\n
\n\n\n\nWhat about the Vim footers?<\/h2>\n\n\n\n
Often times you come across a file with something like the following at the top or bottom<\/p>\n\n\n\n
\/\/ vim: noai:ts=4:sw=4\n -or-\n\/* vim: noai:ts=4:sw=4\n*\/\n -or-\n\/* vim: set noai ts=4 sw=4: *\/\n -or-\n\/* vim: set fdm=expr fde=getline(v\\:lnum)=~'{'?'>1'\\:'1': *\/\n<\/pre>\n\n\n\nThese are called \"vim modelines<\/a>\". The modeline can be within the first or last 5 lines in your file.<\/p>\n\n\n\nBest to only trust modelines on files where you trust the authors (like yourself).<\/p>\n\n\n\n
Unfortunately modeline<\/code> has been abused before. There are at least 5 CVE related modeline exploits over the years<\/a>, so you're probably better off using \"EditorConfig<\/a>\" for shared projects.<\/p>\n","protected":false},"excerpt":{"rendered":"For more than 20 years I’ve been coming across files that have a headers or footers like: Yet I’ve never found exactly where\/how either of these tags are generated… Perhaps it just never got my attention enough. Well, all of that changes now. The rcs (GNU RCS revision control system) first released in 1991, includes […]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/erwin.co\/wp-json\/wp\/v2\/posts\/52"}],"collection":[{"href":"https:\/\/erwin.co\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/erwin.co\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/erwin.co\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/erwin.co\/wp-json\/wp\/v2\/comments?post=52"}],"version-history":[{"count":1,"href":"https:\/\/erwin.co\/wp-json\/wp\/v2\/posts\/52\/revisions"}],"predecessor-version":[{"id":53,"href":"https:\/\/erwin.co\/wp-json\/wp\/v2\/posts\/52\/revisions\/53"}],"wp:attachment":[{"href":"https:\/\/erwin.co\/wp-json\/wp\/v2\/media?parent=52"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/erwin.co\/wp-json\/wp\/v2\/categories?post=52"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/erwin.co\/wp-json\/wp\/v2\/tags?post=52"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}