{"id":29,"date":"2014-07-13T00:00:43","date_gmt":"2014-07-12T22:00:43","guid":{"rendered":"http:\/\/kurt.www.pinboard.jp\/blog\/?p=29"},"modified":"2014-07-15T17:19:50","modified_gmt":"2014-07-15T15:19:50","slug":"save-and-quit","status":"publish","type":"post","link":"http:\/\/kurt.www.pinboard.jp\/blog\/kurt\/29\/","title":{"rendered":"save and quit"},"content":{"rendered":"<p>You all know how to save and quit a file in vim. I see most people using <span style=\"color: #008000\">:wq!<\/span> every time. I&#8217;m not quite happy with this.<!--more--> This command will save the file even if it has not been changed, and thus change the timestamp on the file, and it will also try to write to read-only files. I usually use the command <span style=\"color: #008000\">ZZ<\/span>, which is not only easier to type, but also saves the file only if there have been changes to it. When there were no changes to the file, this command simply quit the editor. <span style=\"color: #008000\">ZZ<\/span> is the same as <span style=\"color: #008000\">:x<\/span>. With the latter, you can also say this should be done for all open files: <span style=\"color: #008000\">:xa<\/span>.<\/p>\n<table>\n<tbody valign=\"&quot;top2\">\n<tr>\n<td><span style=\"color: #008000\">:wq<\/span><\/td>\n<td><\/td>\n<td><\/td>\n<td>write current file and quit<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color: #008000\">:wq!<\/span><\/td>\n<td><\/td>\n<td><\/td>\n<td>write current file even if read-only and quit<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td style=\"color: green;\">:x<\/td>\n<td style=\"background-color:lightyellow; color: green;\">ZZ<\/td>\n<td>write current file if changed and quit<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color: #008000\">:wqa<\/span><\/td>\n<td style=\"background-color:lightyellow; color: green;\">:xa<\/td>\n<td><\/td>\n<td>write all changed files and quit<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color: #008000\">:wqa!<\/span><\/td>\n<td><span style=\"color: #008000\">:xa!<\/span><\/td>\n<td><\/td>\n<td>write all changed files even if read-only and quit<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:lightyellow; color: green;\">:q<\/td>\n<td><\/td>\n<td><\/td>\n<td>quit current file if unchanged<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color: #008000\">:q!<\/span><\/td>\n<td><\/td>\n<td style=\"color: green;\">ZQ<\/td>\n<td>quit current file, ignoring any changes<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:lightyellow; color: green;\">:qa<\/td>\n<td><\/td>\n<td><\/td>\n<td>quit all files if unchanged<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color: #008000\">:qa!<\/span><\/td>\n<td><\/td>\n<td><\/td>\n<td>quit all files, ignoring changes<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>You all know how to save and quit a file in vim. I see most people using :wq! every time. I&#8217;m not quite happy with this.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[5,6],"_links":{"self":[{"href":"http:\/\/kurt.www.pinboard.jp\/blog\/wp-json\/wp\/v2\/posts\/29"}],"collection":[{"href":"http:\/\/kurt.www.pinboard.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/kurt.www.pinboard.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/kurt.www.pinboard.jp\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/kurt.www.pinboard.jp\/blog\/wp-json\/wp\/v2\/comments?post=29"}],"version-history":[{"count":3,"href":"http:\/\/kurt.www.pinboard.jp\/blog\/wp-json\/wp\/v2\/posts\/29\/revisions"}],"predecessor-version":[{"id":45,"href":"http:\/\/kurt.www.pinboard.jp\/blog\/wp-json\/wp\/v2\/posts\/29\/revisions\/45"}],"wp:attachment":[{"href":"http:\/\/kurt.www.pinboard.jp\/blog\/wp-json\/wp\/v2\/media?parent=29"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/kurt.www.pinboard.jp\/blog\/wp-json\/wp\/v2\/categories?post=29"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/kurt.www.pinboard.jp\/blog\/wp-json\/wp\/v2\/tags?post=29"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}