{"id":160332,"date":"2019-10-19T08:00:37","date_gmt":"2019-10-19T00:00:37","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=160332"},"modified":"2019-09-28T10:59:49","modified_gmt":"2019-09-28T02:59:49","slug":"linux-vi-vim","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/linux-vi-vim.html","title":{"rendered":"\u6559\u4f60\u73a9\u8f6cLinux\u2014vi\/vim"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u6240\u6709\u7684 Unix Like \u7cfb\u7edf\u90fd\u4f1a\u5185\u5efa vi \u6587\u4e66\u7f16\u8f91\u5668\uff0c\u5176\u4ed6\u7684\u6587\u4e66\u7f16\u8f91\u5668\u5219\u4e0d\u4e00\u5b9a\u4f1a\u5b58\u5728\u3002
\n\u4f46\u662f\u76ee\u524d\u6211\u4eec\u4f7f\u7528\u6bd4\u8f83\u591a\u7684\u662f vim \u7f16\u8f91\u5668\u3002
\nvim \u5177\u6709\u7a0b\u5e8f\u7f16\u8f91\u7684\u80fd\u529b\uff0c\u53ef\u4ee5\u4e3b\u52a8\u7684\u4ee5\u5b57\u4f53\u989c\u8272\u8fa8\u522b\u8bed\u6cd5\u7684\u6b63\u786e\u6027\uff0c\u65b9\u4fbf\u7a0b\u5e8f\u8bbe\u8ba1\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u4ec0\u4e48\u662f vim\uff1f<\/strong><\/div>\n

Vim\u662f\u4ece vi \u53d1\u5c55\u51fa\u6765\u7684\u4e00\u4e2a\u6587\u672c\u7f16\u8f91\u5668\u3002\u4ee3\u7801\u8865\u5b8c\u3001\u7f16\u8bd1\u53ca\u9519\u8bef\u8df3\u8f6c\u7b49\u65b9\u4fbf\u7f16\u7a0b\u7684\u529f\u80fd\u7279\u522b\u4e30\u5bcc\uff0c\u5728\u7a0b\u5e8f\u5458\u4e2d\u88ab\u5e7f\u6cdb\u4f7f\u7528\u3002<\/p>\n

\u7b80\u5355\u7684\u6765\u8bf4\uff0c vi \u662f\u8001\u5f0f\u7684\u5b57\u5904\u7406\u5668\uff0c\u4e0d\u8fc7\u529f\u80fd\u5df2\u7ecf\u5f88\u9f50\u5168\u4e86\uff0c\u4f46\u662f\u8fd8\u662f\u6709\u53ef\u4ee5\u8fdb\u6b65\u7684\u5730\u65b9\u3002 vim \u5219\u53ef\u4ee5\u8bf4\u662f\u7a0b\u5e8f\u5f00\u53d1\u8005\u7684\u4e00\u9879\u5f88\u597d\u7528\u7684\u5de5\u5177\u3002<\/p>\n

\u8fde vim \u7684\u5b98\u65b9\u7f51\u7ad9 (http:\/\/www.vim.org) \u81ea\u5df1\u4e5f\u8bf4 vim \u662f\u4e00\u4e2a\u7a0b\u5e8f\u5f00\u53d1\u5de5\u5177\u800c\u4e0d\u662f\u6587\u5b57\u5904\u7406\u8f6f\u4ef6\u3002
\nvim \u952e\u76d8\u56fe\uff1a
\n\"\"<\/p>\n

vi\/vim \u7684\u4f7f\u7528<\/strong><\/div>\n

\u57fa\u672c\u4e0a vi\/vim \u5171\u5206\u4e3a\u4e09\u79cd\u6a21\u5f0f\uff0c\u5206\u522b\u662f\u547d\u4ee4\u6a21\u5f0f\uff08Command mode\uff09\uff0c\u8f93\u5165\u6a21\u5f0f\uff08Insert mode\uff09\u548c\u5e95\u7ebf\u547d\u4ee4\u6a21\u5f0f\uff08Last line mode\uff09\u3002 \u8fd9\u4e09\u79cd\u6a21\u5f0f\u7684\u4f5c\u7528\u5206\u522b\u662f\uff1a<\/p>\n

\u547d\u4ee4\u6a21\u5f0f\uff1a<\/strong><\/span><\/div>\n

\u7528\u6237\u521a\u521a\u542f\u52a8 vi\/vim\uff0c\u4fbf\u8fdb\u5165\u4e86\u547d\u4ee4\u6a21\u5f0f\u3002<\/p>\n

\u6b64\u72b6\u6001\u4e0b\u6572\u51fb\u952e\u76d8\u52a8\u4f5c\u4f1a\u88abVim\u8bc6\u522b\u4e3a\u547d\u4ee4\uff0c\u800c\u975e\u8f93\u5165\u5b57\u7b26\u3002\u6bd4\u5982\u6211\u4eec\u6b64\u65f6\u6309\u4e0bi\uff0c\u5e76\u4e0d\u4f1a\u8f93\u5165\u4e00\u4e2a\u5b57\u7b26\uff0ci\u88ab\u5f53\u4f5c\u4e86\u4e00\u4e2a\u547d\u4ee4\u3002<\/p>\n

\u4ee5\u4e0b\u662f\u5e38\u7528\u7684\u51e0\u4e2a\u547d\u4ee4\uff1a<\/p>\n

i \u5207\u6362\u5230\u8f93\u5165\u6a21\u5f0f\uff0c\u4ee5\u8f93\u5165\u5b57\u7b26\u3002
\nx \u5220\u9664\u5f53\u524d\u5149\u6807\u6240\u5728\u5904\u7684\u5b57\u7b26\u3002
\n: \u5207\u6362\u5230\u5e95\u7ebf\u547d\u4ee4\u6a21\u5f0f\uff0c\u4ee5\u5728\u6700\u5e95\u4e00\u884c\u8f93\u5165\u547d\u4ee4\u3002
\n\u82e5\u60f3\u8981\u7f16\u8f91\u6587\u672c\uff1a\u542f\u52a8Vim\uff0c\u8fdb\u5165\u4e86\u547d\u4ee4\u6a21\u5f0f\uff0c\u6309\u4e0bi\uff0c\u5207\u6362\u5230\u8f93\u5165\u6a21\u5f0f\u3002<\/p>\n

\u547d\u4ee4\u6a21\u5f0f\u53ea\u6709\u4e00\u4e9b\u6700\u57fa\u672c\u7684\u547d\u4ee4\uff0c\u56e0\u6b64\u4ecd\u8981\u4f9d\u9760\u5e95\u7ebf\u547d\u4ee4\u6a21\u5f0f\u8f93\u5165\u66f4\u591a\u547d\u4ee4\u3002<\/p>\n

\u8f93\u5165\u6a21\u5f0f<\/strong><\/span><\/div>\n

\u5728\u547d\u4ee4\u6a21\u5f0f\u4e0b\u6309\u4e0bi\u5c31\u8fdb\u5165\u4e86\u8f93\u5165\u6a21\u5f0f\u3002<\/p>\n

\u5728\u8f93\u5165\u6a21\u5f0f\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u6309\u952e\uff1a<\/p>\n

\u5b57\u7b26\u6309\u952e\u4ee5\u53caShift\u7ec4\u5408\uff0c\u8f93\u5165\u5b57\u7b26
\nENTER\uff0c\u56de\u8f66\u952e\uff0c\u6362\u884c
\nBACK SPACE\uff0c\u9000\u683c\u952e\uff0c\u5220\u9664\u5149\u6807\u524d\u4e00\u4e2a\u5b57\u7b26
\nDEL\uff0c\u5220\u9664\u952e\uff0c\u5220\u9664\u5149\u6807\u540e\u4e00\u4e2a\u5b57\u7b26
\n\u65b9\u5411\u952e\uff0c\u5728\u6587\u672c\u4e2d\u79fb\u52a8\u5149\u6807
\nHOME\/END\uff0c\u79fb\u52a8\u5149\u6807\u5230\u884c\u9996\/\u884c\u5c3e
\nPage Up\/Page Down\uff0c\u4e0a\/\u4e0b\u7ffb\u9875
\nInsert\uff0c\u5207\u6362\u5149\u6807\u4e3a\u8f93\u5165\/\u66ff\u6362\u6a21\u5f0f\uff0c\u5149\u6807\u5c06\u53d8\u6210\u7ad6\u7ebf\/\u4e0b\u5212\u7ebf
\nESC\uff0c\u9000\u51fa\u8f93\u5165\u6a21\u5f0f\uff0c\u5207\u6362\u5230\u547d\u4ee4\u6a21\u5f0f<\/p>\n

\u5e95\u7ebf\u547d\u4ee4\u6a21\u5f0f<\/strong><\/span><\/div>\n

\u5728\u547d\u4ee4\u6a21\u5f0f\u4e0b\u6309\u4e0b:\uff08\u82f1\u6587\u5192\u53f7\uff09\u5c31\u8fdb\u5165\u4e86\u5e95\u7ebf\u547d\u4ee4\u6a21\u5f0f\u3002<\/p>\n

\u5e95\u7ebf\u547d\u4ee4\u6a21\u5f0f\u53ef\u4ee5\u8f93\u5165\u5355\u4e2a\u6216\u591a\u4e2a\u5b57\u7b26\u7684\u547d\u4ee4\uff0c\u53ef\u7528\u7684\u547d\u4ee4\u975e\u5e38\u591a\u3002<\/p>\n

\u5728\u5e95\u7ebf\u547d\u4ee4\u6a21\u5f0f\u4e2d\uff0c\u57fa\u672c\u7684\u547d\u4ee4\u6709\uff08\u5df2\u7ecf\u7701\u7565\u4e86\u5192\u53f7\uff09\uff1a<\/p>\n

q \u9000\u51fa\u7a0b\u5e8f
\nw \u4fdd\u5b58\u6587\u4ef6
\n\u6309ESC\u952e\u53ef\u968f\u65f6\u9000\u51fa\u5e95\u7ebf\u547d\u4ee4\u6a21\u5f0f\u3002<\/p>\n

\u7b80\u5355\u7684\u8bf4\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u8fd9\u4e09\u4e2a\u6a21\u5f0f\u60f3\u6210\u5e95\u4e0b\u7684\u56fe\u6807\u6765\u8868\u793a\uff1a
\n\"\"<\/p>\n

vi\/vim \u4f7f\u7528\u5b9e\u4f8b<\/strong><\/div>\n
\u4f7f\u7528 vi\/vim \u8fdb\u5165\u4e00\u822c\u6a21\u5f0f<\/strong><\/span><\/div>\n

\u5982\u679c\u4f60\u60f3\u8981\u4f7f\u7528 vi \u6765\u5efa\u7acb\u4e00\u4e2a\u540d\u4e3a runoob.txt \u7684\u6587\u4ef6\u65f6\uff0c\u4f60\u53ef\u4ee5\u8fd9\u6837\u505a\uff1a<\/p>\n

$ vim runoob.txt<\/pre>\n

\u76f4\u63a5\u8f93\u5165 vi \u6587\u4ef6\u540d \u5c31\u80fd\u591f\u8fdb\u5165 vi \u7684\u4e00\u822c\u6a21\u5f0f\u4e86\u3002\u8bf7\u6ce8\u610f\uff0c\u8bb0\u5f97 vi \u540e\u9762\u4e00\u5b9a\u8981\u52a0\u6587\u4ef6\u540d\uff0c\u4e0d\u7ba1\u8be5\u6587\u4ef6\u5b58\u5728\u4e0e\u5426\uff01
\n\"\"<\/p>\n

\u6309\u4e0b i \u8fdb\u5165\u8f93\u5165\u6a21\u5f0f(\u4e5f\u79f0\u4e3a\u7f16\u8f91\u6a21\u5f0f)\uff0c\u5f00\u59cb\u7f16\u8f91\u6587\u5b57<\/strong><\/span><\/div>\n

\u5728\u4e00\u822c\u6a21\u5f0f\u4e4b\u4e2d\uff0c\u53ea\u8981\u6309\u4e0b i, o, a \u7b49\u5b57\u7b26\u5c31\u53ef\u4ee5\u8fdb\u5165\u8f93\u5165\u6a21\u5f0f\u4e86\uff01<\/p>\n

\u5728\u7f16\u8f91\u6a21\u5f0f\u5f53\u4e2d\uff0c\u4f60\u53ef\u4ee5\u53d1\u73b0\u5728\u5de6\u4e0b\u89d2\u72b6\u6001\u680f\u4e2d\u4f1a\u51fa\u73b0 \u2013INSERT- \u7684\u5b57\u6837\uff0c\u90a3\u5c31\u662f\u53ef\u4ee5\u8f93\u5165\u4efb\u610f\u5b57\u7b26\u7684\u63d0\u793a\u3002<\/p>\n

\u8fd9\u4e2a\u65f6\u5019\uff0c\u952e\u76d8\u4e0a\u9664\u4e86 Esc \u8fd9\u4e2a\u6309\u952e\u4e4b\u5916\uff0c\u5176\u4ed6\u7684\u6309\u952e\u90fd\u53ef\u4ee5\u89c6\u4f5c\u4e3a\u4e00\u822c\u7684\u8f93\u5165\u6309\u94ae\u4e86\uff0c\u6240\u4ee5\u4f60\u53ef\u4ee5\u8fdb\u884c\u4efb\u4f55\u7684\u7f16\u8f91\u3002
\n\"\"<\/p>\n

\u6309\u4e0b ESC \u6309\u94ae\u56de\u5230\u4e00\u822c\u6a21\u5f0f<\/strong><\/span><\/div>\n

\u597d\u4e86\uff0c\u5047\u8bbe\u6211\u5df2\u7ecf\u6309\u7167\u4e0a\u9762\u7684\u6837\u5f0f\u7ed9\u4ed6\u7f16\u8f91\u5b8c\u6bd5\u4e86\uff0c\u90a3\u4e48\u5e94\u8be5\u8981\u5982\u4f55\u9000\u51fa\u5462\uff1f\u662f\u7684\uff01\u6ca1\u9519\uff01\u5c31\u662f\u7ed9\u4ed6\u6309\u4e0b Esc \u8fd9\u4e2a\u6309\u94ae\u5373\u53ef\uff01\u9a6c\u4e0a\u4f60\u5c31\u4f1a\u53d1\u73b0\u753b\u9762\u5de6\u4e0b\u89d2\u7684 \u2013 INSERT \u2013 \u4e0d\u89c1\u4e86\uff01<\/p>\n

\u5728\u4e00\u822c\u6a21\u5f0f\u4e2d\u6309\u4e0b :wq \u50a8\u5b58\u540e\u79bb\u5f00 vi<\/strong><\/span><\/div>\n

OK\uff0c\u6211\u4eec\u8981\u5b58\u6863\u4e86\uff0c\u5b58\u76d8\u5e76\u79bb\u5f00\u7684\u6307\u4ee4\u5f88\u7b80\u5355\uff0c\u8f93\u5165 :wq \u5373\u53ef\u4fdd\u5b58\u79bb\u5f00\uff01
\n\"\"
\nOK! \u8fd9\u6837\u6211\u4eec\u5c31\u6210\u529f\u521b\u5efa\u4e86\u4e00\u4e2a runoob.txt \u7684\u6587\u4ef6\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

Vim\u662f\u4ece vi \u53d1\u5c55\u51fa\u6765\u7684\u4e00\u4e2a\u6587\u672c\u7f16\u8f91\u5668\u3002\u4ee3\u7801\u8865\u5b8c\u3001\u7f16\u8bd1\u53ca\u9519\u8bef\u8df3\u8f6c\u7b49\u65b9\u4fbf\u7f16\u7a0b\u7684\u529f\u80fd\u7279\u522b\u4e30\u5bcc\uff0c\u5728\u7a0b\u5e8f\u5458\u4e2d\u88ab\u5e7f\u6cdb […]<\/p>\n","protected":false},"author":1470,"featured_media":160338,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-160332","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/160332","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1470"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=160332"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/160332\/revisions"}],"predecessor-version":[{"id":160340,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/160332\/revisions\/160340"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/160338"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=160332"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=160332"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=160332"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}