{"id":651,"date":"2023-02-14T10:21:03","date_gmt":"2023-02-14T02:21:03","guid":{"rendered":"https:\/\/www.anger.ltd\/?p=651"},"modified":"2023-02-14T10:24:27","modified_gmt":"2023-02-14T02:24:27","slug":"%e4%bd%bf%e7%94%a8vim%e7%bc%96%e8%be%91%e5%99%a8%e6%97%b6%ef%bc%8c%e8%87%aa%e5%8a%a8%e6%b7%bb%e5%8a%a0%e4%bd%9c%e8%80%85%e4%bf%a1%e6%81%af","status":"publish","type":"post","link":"https:\/\/www.anger.ltd\/index.php\/2023\/02\/14\/%e4%bd%bf%e7%94%a8vim%e7%bc%96%e8%be%91%e5%99%a8%e6%97%b6%ef%bc%8c%e8%87%aa%e5%8a%a8%e6%b7%bb%e5%8a%a0%e4%bd%9c%e8%80%85%e4%bf%a1%e6%81%af\/","title":{"rendered":"\u4f7f\u7528vim\u7f16\u8f91\u5668\u65f6\uff0c\u81ea\u52a8\u6dfb\u52a0\u4f5c\u8005\u4fe1\u606f"},"content":{"rendered":"\n<h5 class=\"wp-block-heading\">\u7f16\u8f91\u6587\u4ef6<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>#\u8fd9\u6837\u4fee\u6539\u4f1a\u88ab\u6240\u6709\u7528\u6237\u4f7f\u7528\nvim \/etc\/vimrc\n#\u4e5f\u53ef\u4ee5\u5728\u7528\u6237\u76ee\u5f55\u4fee\u6539.vimrc\u6587\u4ef6\nvim ~\/.vimrc<\/code><\/pre>\n\n\n\n<p>\u5728\u6587\u4ef6\u672b\u7aef\u52a0\u5165\u4e0b\u9762\u7684\u5185\u5bb9<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>map &lt;F4&gt; ms:call AddAuthor()&lt;cr&gt;'S\nfunction AddAuthor()\n    let n=1\n    while n &lt; 11\n        let line = getline(n)\n        if line=~'&#91;#]*\\s*\\*\\s*\\S*Last\\s*modified\\s*:\\s*\\S*.*$'\n        call UpdateTitle()\n        return\n    endif\n    let n = n + 1\n    endwhile\n    if &amp;filetype == 'sh'\n        call AddTitleForShell()\n    elseif &amp;filetype == 'python'\n        call AddTitleForPython()\n    else\n        call AddTitleForC()\n    endif\n\nendfunction\n\n\"\" \u8868\u793a\u975e.sh\u6216.py\u7ed3\u5c3e\u7684\u6587\u4ef6\u6dfb\u52a0\u6b64\u51fd\u6570\u6ce8\u91ca\nfunction AddTitleForC()\n    call append(0,\"# **********************************************************\")\n    call append(1,\"\")\n    call append(2,\"# * Create time   : \".strftime(\"%Y-%m-%d %H:%M\"))\n    call append(3,\"# * Filename      : \".expand(\"%:t\"))\n    call append(4,\"\")\n    call append(5,\"# **********************************************************\")\nendfunction\n\n\"\" \u8868\u793a.py\u6dfb\u52a0\u6b64\u51fd\u6570\u6ce8\u91ca\nfunction AddTitleForPython()\n    call append(0,\"#!\/usr\/bin\/env python\")\n    call append(1,\"# coding:utf-8\")\n    call append(2,\"\")\n    call append(3,\"# **********************************************************\")\n    call append(4,\"# * Author        : anger\")\n    call append(5,\"# * Email         : xxx@xxx.com\")\n    call append(6,\"# * Create time   : \".strftime(\"%Y-%m-%d %H:%M\"))\n    call append(7,\"# * Last modified : \".strftime(\"%Y-%m-%d %H:%M\"))\n    call append(8,\"# * Filename      : \".expand(\"%:t\"))\n    call append(9,\"# * Description   : \")\n    call append(10,\"# **********************************************************\")\n    echohl WarningMsg | echo \"Successful in adding the copyright.\" | echohl None\nendfunction\n\n\"\" \u8868\u793a.sh\u6587\u4ef6\u6dfb\u52a0\u6b64\u884c\u6570\u6ce8\u91ca\nfunction AddTitleForShell()\n    call append(0,\"#!\/bin\/bash\")\n    call append(1,\"# **********************************************************\")\n    call append(2,\"# * Author        : anger\")\n    call append(3,\"# * Email         : xxx@xxx.com\")\n    call append(4,\"# * Create time   : \".strftime(\"%Y-%m-%d %H:%M\"))\n    call append(5,\"# * Last modified : \".strftime(\"%Y-%m-%d %H:%M\"))\n    call append(6,\"# * Filename      : \".expand(\"%:t\"))\n    call append(7,\"# * Description   : \")\n    call append(8,\"# **********************************************************\")\nendfunction<\/code><\/pre>\n\n\n\n<p>\u6dfb\u52a0\u5b8c\u6210\u540e\u4fdd\u5b58\uff0c\u8bb0\u5f97\u4fee\u6539\u4e2d\u95f4\u4f5c\u8005\u90ae\u7bb1\u4e4b\u7c7b\u7684\u4fe1\u606f\u6210\u81ea\u5df1\u7684<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">\u4f7f\u7528<\/h5>\n\n\n\n<p>\u4f7f\u7528vim\u7f16\u8f91\u6587\u6863\u65f6\u5019\u6309F4\u5c31\u53ef\u4ee5\u81ea\u52a8\u6dfb\u52a0\u4f5c\u8005\u4fe1\u606f<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"954\" height=\"851\" src=\"https:\/\/www.anger.ltd\/wp-content\/uploads\/2023\/02\/image-2.png\" alt=\"\" class=\"wp-image-652\" srcset=\"https:\/\/www.anger.ltd\/wp-content\/uploads\/2023\/02\/image-2.png 954w, https:\/\/www.anger.ltd\/wp-content\/uploads\/2023\/02\/image-2-300x268.png 300w, https:\/\/www.anger.ltd\/wp-content\/uploads\/2023\/02\/image-2-768x685.png 768w, https:\/\/www.anger.ltd\/wp-content\/uploads\/2023\/02\/image-2-392x350.png 392w\" sizes=\"auto, (max-width: 954px) 100vw, 954px\" \/><\/figure><\/div>","protected":false},"excerpt":{"rendered":"<p>\u7f16\u8f91\u6587\u4ef6 \u5728\u6587\u4ef6\u672b\u7aef\u52a0\u5165\u4e0b\u9762\u7684\u5185\u5bb9 \u6dfb\u52a0\u5b8c\u6210\u540e\u4fdd\u5b58\uff0c\u8bb0\u5f97\u4fee\u6539\u4e2d\u95f4\u4f5c\u8005\u90ae\u7bb1\u4e4b\u7c7b\u7684\u4fe1\u606f\u6210\u81ea\u5df1\u7684 \u4f7f\u7528 \u4f7f\u7528vim\u7f16\u8f91\u6587\u6863\u65f6\u5019\u6309F4\u5c31\u53ef\u4ee5\u81ea\u52a8\u6dfb\u52a0\u4f5c\u8005\u4fe1\u606f<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-651","post","type-post","status-publish","format-standard","hentry","category-3"],"_links":{"self":[{"href":"https:\/\/www.anger.ltd\/index.php\/wp-json\/wp\/v2\/posts\/651","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.anger.ltd\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.anger.ltd\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.anger.ltd\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.anger.ltd\/index.php\/wp-json\/wp\/v2\/comments?post=651"}],"version-history":[{"count":3,"href":"https:\/\/www.anger.ltd\/index.php\/wp-json\/wp\/v2\/posts\/651\/revisions"}],"predecessor-version":[{"id":655,"href":"https:\/\/www.anger.ltd\/index.php\/wp-json\/wp\/v2\/posts\/651\/revisions\/655"}],"wp:attachment":[{"href":"https:\/\/www.anger.ltd\/index.php\/wp-json\/wp\/v2\/media?parent=651"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.anger.ltd\/index.php\/wp-json\/wp\/v2\/categories?post=651"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.anger.ltd\/index.php\/wp-json\/wp\/v2\/tags?post=651"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}