{"id":4373,"date":"2020-03-27T00:16:54","date_gmt":"2020-03-26T16:16:54","guid":{"rendered":"https:\/\/vip.fxxkpython.com\/?p=4373"},"modified":"2020-03-27T00:16:58","modified_gmt":"2020-03-26T16:16:58","slug":"%e5%b7%a5%e5%85%b7%e7%af%87-%e6%95%99%e4%bd%a0%e5%bc%84%e4%b8%80%e4%b8%aa%e9%85%b7%e7%82%ab%e7%9a%84-python-vim%e7%bc%96%e8%be%91%e5%99%a8-%e6%b7%bb%e5%8a%a0%e4%bb%a3%e7%a0%81-pep8","status":"publish","type":"post","link":"https:\/\/vip.fxxkpython.com\/?p=4373","title":{"rendered":"\u5de5\u5177\u7bc7 | \u6559\u4f60\u5f04\u4e00\u4e2a\u9177\u70ab\u7684 Python Vim\u7f16\u8f91\u5668 \u2014\u2014\u6dfb\u52a0\u4ee3\u7801 pep8 \u68c0\u6d4b\u4fee\u590d\uff0c\u4ee3\u7801\u7f16\u8bd1\u6267\u884c"},"content":{"rendered":"\n<p>\u73b0\u5728\u4f60\u7684 Vim \u5df2\u7ecf\u6709\u6a21\u6709\u6837\u4e86\uff0c\u6211\u4eec\u8fd8\u9700\u8981\u5bf9\u4ee3\u7801\u7684\u884c\u4e3a\u505a\u8fdb\u4e00\u6b65\u7684\u914d\u7f6e\uff0c\u6bd4\u5982\u4ee3\u7801\u7684\u6267\u884c\uff08\u4e0d\u53ef\u80fd\u6bcf\u6b21\u90fd :wq , \u7136\u540e\u7528 Python \u53bb\u6267\u884c\u5427\uff09\uff0c\u4ee3\u7801\u7684\u9519\u8bef\u68c0\u6d4b\u3002<\/p>\n\n\n\n<h2>Vim \u6267\u884c Python \u4ee3\u7801<\/h2>\n\n\n\n<h3>\u5728 normal \u4e0b\u6267\u884c Python<\/h3>\n\n\n\n<p>\u4f60\u53ef\u4ee5\u76f4\u63a5\u5728 Vim \u7684 normal \u4e0b\u8f93\u5165\u5982\u4e0b\u547d\u4ee4\u76f4\u63a5\u4f7f\u7528 Python \u6765\u8fd0\u884c\u7684\u4f60 Python \u4ee3\u7801\uff1a<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>:w !python3<\/p><\/blockquote>\n\n\n\n<p>\u8fd0\u884c\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" width=\"735\" height=\"488\" src=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2020\/03\/Peek-2020-03-26-21-48.gif\" alt=\"\" class=\"wp-image-4374\"\/><\/figure><\/div>\n\n\n\n<p>\u5982\u679c\u4f60\u63a5\u7684\u6bcf\u6b21\u8981\u8fd0\u884c Python \u90fd\u9700\u8981\u8f93\u5165 :w !python3 \u6bd4\u8f83\u9ebb\u70e6\uff0c\u90a3\u4e48\u53ef\u4ee5\u7ed1\u5b9a\u5feb\u6377\u952e\uff0c\u6bd4\u5982\u4f60\u5e0c\u671b\u5728 Vim \u4e2d\u6309 F5 \u5c31\u80fd\u5feb\u901f\u6267\u884c Python \u6587\u4ef6\uff0c\u90a3\u4e48\u4f60\u53ef\u4ee5\u5728 .vimrc \u4e2d\u505a\u5982\u4e0b\u914d\u7f6e\uff1a<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p><code>autocmd FileType python map &lt;buffer> &lt;F5> :w&lt;CR>:exec '!python3' shellescape(@%, 1)&lt;CR> <\/code><\/p><p><code>autocmd FileType python imap &lt;buffer> &lt;F5> &lt;esc>:w&lt;CR>:exec '!python3' shellescape(@%, 1)&lt;CR><\/code><\/p><\/blockquote>\n\n\n\n<p>\u914d\u7f6e\u5b8c\u6210\u4e4b\u540e\uff0c\u4f60\u5728 Vim \u91cc\u9762\u53ea\u9700\u8981\u6309 F5 \u5c31\u53ef\u4ee5\u6267\u884c\u4e86\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" width=\"735\" height=\"488\" src=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2020\/03\/Peek-2020-03-26-21-54.gif\" alt=\"\" class=\"wp-image-4375\"\/><\/figure><\/div>\n\n\n\n<h3 id=\"mce_4\"> \u7ed3\u5408\u63d2\u4ef6\u6267\u884c Python<\/h3>\n\n\n\n<p>\u5982\u679c\u4f60\u5e0c\u671b\u5728\u540c\u4e00\u4e2a\u7a97\u53e3\u770b\u5230 Python \u7684\u6267\u884c\uff0c\u4f60\u8fd8\u53ef\u4ee5\u7ed3\u5408<div style=\"text-align:center;border:1px dashed #FF9A9A;padding:8px;margin:10px auto;color:#FF6666;\">\u672c\u6587\u9690\u85cf\u5185\u5bb9 <a href=\"https:\/\/vip.fxxkpython.com\/wp-login.php?redirect_to=https%3A%2F%2Fvip.fxxkpython.com%2F%3Fp%3D4373\">\u767b\u9646<\/a> \u540e\u624d\u53ef\u4ee5\u6d4f\u89c8<\/div>\u90fd\u5b89\u88c5\u5b8c\u4e4b\u540e\u5c31\u53ef\u4ee5\u4f7f\u7528 :Autopep8 \u6765\u683c\u5f0f\u5316\u4ee3\u7801\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" width=\"735\" height=\"488\" src=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2020\/03\/Peek-2020-03-27-00-06.gif\" alt=\"\" class=\"wp-image-4381\"\/><\/figure><\/div>\n\n\n\n<p>\u5f53\u7136\uff0c\u4f60\u53ef\u4ee5\u5728 vimrc \u914d\u7f6e\u5feb\u6377\u952e\uff0c\u6bd4\u5982\u6309\u4f4f F8 \u5c31\u6267\u884c\uff0c\u53ef\u4ee5\u5728 .vimrc \u4e2d\u505a\u5982\u4e0b\u914d\u7f6e\uff1a<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>&#8221; \u4ee3\u7801\u89c4\u8303\u914d\u7f6e                                                     <br><code>autocmd FileType python noremap &lt;buffer> &lt;F8> :call Autopep8()&lt;CR><\/code>\u3002<br><br><\/p><\/blockquote>\n\n\n\n<p>\u914d\u7f6e\u597d\u4e4b\u540e\u5c31\u53ef\u4ee5\u76f4\u63a5\u5728 normal \u6a21\u5f0f\u4e0b\u4f7f\u7528\u5feb\u6377\u952e\u5feb\u901f\u89c4\u8303\u4ee3\u7801\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" width=\"734\" height=\"488\" src=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2020\/03\/Screenshot-from-2020-03-27-00-10-56.png\" alt=\"\" class=\"wp-image-4382\" srcset=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2020\/03\/Screenshot-from-2020-03-27-00-10-56.png 734w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2020\/03\/Screenshot-from-2020-03-27-00-10-56-300x199.png 300w\" sizes=\"(max-width: 734px) 100vw, 734px\" \/><\/figure><\/div>\n\n\n\n<p>ok\uff0c\u4ee5\u4e0a\u5c31\u662f\u4eca\u5929\u7ed9\u4f60\u5206\u4eab\u7684 Vim \u7684 Python \u4ee3\u7801\u884c\u4e3a\u914d\u7f6e\uff0c\u4e0b\u4e00\u7bc7\u518d\u8ddf\u4f60\u8bf4\u8bf4\u5982\u4f55\u914d\u7f6e\u4f7f\u7528 Vim \u6765 debug \u4f60\u7684 Python \u4ee3\u7801\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p> \u6559\u4f60\u5f04\u4e00\u4e2a\u9177\u70ab\u7684 Python Vim\u7f16\u8f91\u5668 \u2014\u2014\u6dfb\u52a0\u4ee3\u7801 pep8 \u68c0\u6d4b\u4fee\u590d\uff0c\u4ee3\u7801\u7f16\u8bd1\u6267\u884c<\/p>\n","protected":false},"author":1,"featured_media":4382,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[343],"tags":[19,206,368,366,367],"_links":{"self":[{"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts\/4373"}],"collection":[{"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4373"}],"version-history":[{"count":5,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts\/4373\/revisions"}],"predecessor-version":[{"id":4383,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts\/4373\/revisions\/4383"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/media\/4382"}],"wp:attachment":[{"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4373"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4373"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4373"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}