{"id":1380,"date":"2014-10-03T08:22:11","date_gmt":"2014-10-03T08:22:11","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=1380"},"modified":"2014-10-03T08:22:11","modified_gmt":"2014-10-03T08:22:11","slug":"vim%e5%b0%8f%e6%8a%80%e5%b7%a7_3","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/1380.html","title":{"rendered":"VIM\u5c0f\u6280\u5de7_3"},"content":{"rendered":"<p>\u597d\u4e45\u6ca1\u6709\u66f4\u65b0\u548cVim\u76f8\u5173\u7684\u5185\u5bb9\u4e86\uff0c\u4e00\u65b9\u9762\u662f\u4e4b\u524d\u6536\u96c6\u7684\u4e00\u4e9b\u6280\u5de7\u5df2\u7ecf\u591f\u7528\u4e86\uff0880\/20\u539f\u5219\uff09\uff0c\u53e6\u4e00\u65b9\u9762\u662f\u56e0\u4e3a\u81ea\u5df1\u8ba4\u8bc6\u5230\uff0c\u5373\u4f7fVim\u4f7f\u7528\u7684\u518d\u719f\u7ec3\uff0c\u4f46\u662f\u5982\u679c\u4ee3\u7801\u5199\u5f97\u4e0d\u597d\uff08\u529f\u80fd\u65e0\u6cd5\u5b8c\u5584\uff0c\u5bb9\u9519\u6027\u8f83\u4f4e\uff0c\u5065\u58ee\u6027\u8f83\u4f4e\u2026\u2026\uff09\u8fd9\u4e00\u5207\u53c8\u6709\u4ec0\u4e48\u610f\u4e49\u5462\uff1f\u8fd8\u662f\u60f3\u529e\u6cd5\u53bb\u63d0\u9ad8\u4ee3\u7801\u80fd\u529b\u5427\uff0c\u7f16\u8f91\u5668\u8fd9\u6863\u5b50\u4e8b\u53ef\u4ee5\u5148\u7f13\u7f13\u4e86\uff0c\u591f\u7528\u5c31\u884c\uff0c\u522b\u504f\u6267\u3002\u4e0b\u9762\u7684\u5185\u5bb9\u662f\u5728\u901b\u7b80\u4e66\u7684\u65f6\u5019\u770b\u5230\u7684\u548cVim\u4f7f\u7528\u76f8\u5173\u7684\u6587\u7ae0\uff0c\u5176\u4e2d\u6709\u4e9b\u662f\u4e4b\u524d\u6ca1\u600e\u4e48\u6ce8\u610for\u4e0d\u77e5\u9053\u7684\uff0c\u6536\u96c6\u5907\u7528\uff1a<\/p>\n<h4>Vim\u7684\u6b63\u5219\u8868\u8fbe\u5f0f<\/h4>\n<h5>\u5143\u5b57\u7b26<\/h5>\n<p>\u53ef\u7406\u89e3\u4e3a\u5173\u952e\u5b57\u6216\u4fdd\u7559\u5b57\uff0c\u8fd9\u4e9b\u5b57\u7b26\u505a\u7279\u6b8a\u7528\u9014<\/p>\n<table>\n<thead>\n<tr>\n<th>\u5b57\u7b26<\/th>\n<th>\u89e3\u91ca<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>.<\/td>\n<td>\u5339\u914d\u6362\u884c\u7b26\u4ee5\u5916\u7684\u4efb\u610f\u5b57\u7b26<\/td>\n<\/tr>\n<tr>\n<td>^<\/td>\n<td>\u5339\u914d\u5b57\u7b26\u4e32\u7684\u5f00\u59cb\u4f4d\u7f6e<\/td>\n<\/tr>\n<tr>\n<td>$<\/td>\n<td>\u5339\u914d\u5b57\u7b26\u4e32\u7684\u7ed3\u675f\u4f4d\u7f6e<\/td>\n<\/tr>\n<tr>\n<td>*<\/td>\n<td>\u5339\u914d\u524d\u9762\u7684\u5b50\u8868\u8fbe\u5f0f\u96f6\u6b21\u6216\u591a\u6b21\uff0c\u7b49\u4ef7\u4e8e{0,}<\/td>\n<\/tr>\n<tr>\n<td>+<\/td>\n<td>\u5339\u914d\u524d\u9762\u7684\u5b50\u8868\u8fbe\u5f0f\u4e00\u6b21\u6216\u591a\u6b21\uff0c\u7b49\u4ef7\u4e8e{1,}<\/td>\n<\/tr>\n<tr>\n<td>?<\/td>\n<td>\u5339\u914d\u524d\u9762\u7684\u5b50\u8868\u8fbe\u5f0f\u96f6\u6b21\u6216\u4e00\u6b21\uff0c\u7b49\u4ef7\u4e8e{0,1}<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td>\u8f6c\u4e49\u7b26\uff0c\u5c06\u7279\u6b8a\u5b57\u7b26\u8fdb\u884c\u8f6c\u4e49<\/td>\n<\/tr>\n<tr>\n<td>[]<\/td>\n<td>[abc]\u5b57\u7b26\u96c6\u5408\uff0c\u5339\u914d\u6240\u5305\u542b\u7684\u4efb\u610f\u4e00\u4e2a\u5b57\u7b26<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td>[^abc]\u8d1f\u503c\u5b57\u7b26\u96c6\u5408,\u5339\u914d\u672a\u5305\u542b\u7684\u4efb\u610f\u5b57\u7b26<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td>[a-z] \u5b57\u7b26\u8303\u56f4\uff0c\u5339\u914d\u6307\u5b9a\u8303\u56f4\u5185\u7684\u4efb\u610f\u5b57\u7b26<\/td>\n<\/tr>\n<tr>\n<td>()<\/td>\n<td>\u4e24\u4e2a\u5b57\u7b26\u4e00\u8d77\u4f7f\u7528\uff0c\u7528\u4e8e\u521b\u5efa\u4e00\u4e2a\u7528\u4e8e\u5339\u914d\u7684\u5b50\u4e32\uff0c\u4e5f\u53eb\u5206\u7ec4<\/td>\n<\/tr>\n<tr>\n<td>{}<\/td>\n<td>{n}\u5339\u914d\u786e\u5b9a\u7684n\u6b21<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td>{n,}\u81f3\u5c11\u5339\u914dn\u6b21\uff0c\u7b49\u4ef7\u4e8e&#8221;*&#8221;<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td>{n,m}\u6700\u5c11\u5339\u914dn\u6b21\u4e14\u6700\u591a\u5339\u914dm\u6b21\uff08\u5176\u4e2dn&lt;=m\uff09<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8fd8\u6709\u00a0<code>|<\/code> \u4ea4\u66ff\u5339\u914d\uff0c\u7b26\u53f7\u4e24\u8fb9\u7684\u4efb\u610f\u4e00\u9879<\/p>\n<h5>\u9884\u8bbe\u5b57\u7b26<\/h5>\n<table>\n<thead>\n<tr>\n<th>\u5b57\u7b26<\/th>\n<th>\u89e3\u91ca<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>b<\/td>\n<td>\u5355\u8bcd\u8fb9\u754c\uff0c\u540c&lt;<\/td>\n<\/tr>\n<tr>\n<td>B<\/td>\n<td>\u975e\u5355\u8bcd\u8fb9\u754c\uff0c\u540c &gt;<\/td>\n<\/tr>\n<tr>\n<td>d<\/td>\n<td>\u6570\u5b57\u5b57\u7b26\uff0c\u540c [0-9]<\/td>\n<\/tr>\n<tr>\n<td>D<\/td>\n<td>\u975e\u6570\u5b57\u5b57\u7b26\uff0c\u540c[^0-9]<\/td>\n<\/tr>\n<tr>\n<td>s<\/td>\n<td>\u7a7a\u767d\u5b57\u7b26\uff0c\u540c [ tnrfv]<\/td>\n<\/tr>\n<tr>\n<td>S<\/td>\n<td>\u975e\u7a7a\u767d\u5b57\u7b26\uff0c\u540c [^tnrfv]<\/td>\n<\/tr>\n<tr>\n<td>w<\/td>\n<td>\u5b57\u6bcd\u6570\u5b57\u5b57\u7b26\uff0c\u540c [a-zA-Z0-9_]<\/td>\n<\/tr>\n<tr>\n<td>W<\/td>\n<td>\u975e\u5b57\u6bcd\u6570\u5b57\u5b57\u7b26\uff0c\u540c [^a-zA-Z0-9_]<\/td>\n<\/tr>\n<tr>\n<td>t<\/td>\n<td>Tab\uff0c\u540c0x09<\/td>\n<\/tr>\n<tr>\n<td>r<\/td>\n<td>\u56de\u8f66\u7b26\uff0c\u540c0x0D<\/td>\n<\/tr>\n<tr>\n<td>n<\/td>\n<td>\u6362\u884c\u7b26\uff0c\u540c0x0A<\/td>\n<\/tr>\n<tr>\n<td>f<\/td>\n<td>\u6362\u9875\u7b26<\/td>\n<\/tr>\n<tr>\n<td>v<\/td>\n<td>\u5782\u76f4\u5236\u8868\u7b26\uff0c\u540c0x0b<\/td>\n<\/tr>\n<tr>\n<td>x<\/td>\n<td>\u5341\u516d\u8fdb\u5236\uff0c\u4f8b\u5982\u201cx41\u201d\u5339\u914d\u201cA\u201d<\/td>\n<\/tr>\n<tr>\n<td>u<\/td>\n<td>Unicode\u5b57\u7b26\u3002\u4f8b\u5982\uff0cu00A9\u5339\u914d\u7248\u6743\u7b26\u53f7<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5>POSIX\u5b57\u7b26\u7c7b<\/h5>\n<table>\n<thead>\n<tr>\n<th>\u5b57\u7b26<\/th>\n<th>\u89e3\u91ca<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>[:alnum:]<\/td>\n<td>\u5339\u914d\u4efb\u610f\u4e00\u4e2a\u5b57\u6bcd\u6216\u6570\u5b57\u5b57\u7b26<\/td>\n<\/tr>\n<tr>\n<td>[:alpha:]<\/td>\n<td>\u5339\u914d\u4efb\u610f\u4e00\u4e2a\u5b57\u6bcd\u5b57\u7b26\uff08\u5305\u62ec\u5927\u5c0f\u5199\u5b57\u6bcd\uff09<\/td>\n<\/tr>\n<tr>\n<td>[:blank:]<\/td>\n<td>\u7a7a\u683c\u4e0e\u5236\u8868\u7b26\uff08\u6a2a\u5411\u548c\u7eb5\u5411\uff09<\/td>\n<\/tr>\n<tr>\n<td>[:digit:]<\/td>\n<td>\u5339\u914d\u4efb\u610f\u4e00\u4e2a\u6570\u5b57\u5b57\u7b26<\/td>\n<\/tr>\n<tr>\n<td>[:lower:]<\/td>\n<td>\u5339\u914d\u5c0f\u5199\u5b57\u6bcd<\/td>\n<\/tr>\n<tr>\n<td>[:upper:]<\/td>\n<td>\u5339\u914d\u5927\u5199\u5b57\u6bcd<\/td>\n<\/tr>\n<tr>\n<td>[:punct:]<\/td>\n<td>\u5339\u914d\u6807\u70b9\u7b26\u53f7<\/td>\n<\/tr>\n<tr>\n<td>[:space:]<\/td>\n<td>\u5339\u914d\u4e00\u4e2a\u5305\u62ec\u6362\u884c\u7b26\u3001\u56de\u8f66\u7b49\u5728\u5185\u7684\u6240\u6709\u7a7a\u767d\u7b26<\/td>\n<\/tr>\n<tr>\n<td>[:graph:]<\/td>\n<td>\u5339\u914d\u4efb\u4f55\u4e00\u4e2a\u53ef\u4ee5\u770b\u5f97\u89c1\u7684\u4e14\u53ef\u4ee5\u6253\u5370\u7684\u5b57\u7b26<\/td>\n<\/tr>\n<tr>\n<td>[:xdigit:]<\/td>\n<td>\u4efb\u4f55\u4e00\u4e2a\u5341\u516d\u8fdb\u5236\u6570\uff08\u5373\uff1a0-9\uff0ca-f\uff0cA-F\uff09<\/td>\n<\/tr>\n<tr>\n<td>[:cntrl:]<\/td>\n<td>\u4efb\u4f55\u4e00\u4e2a\u63a7\u5236\u5b57\u7b26\uff08ASCII\u5b57\u7b26\u96c6\u4e2d\u7684\u524d32\u4e2a\u5b57\u7b26)<\/td>\n<\/tr>\n<tr>\n<td>[:print:]<\/td>\n<td>\u4efb\u4f55\u4e00\u4e2a\u53ef\u4ee5\u6253\u5370\u7684\u5b57\u7b26<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5>\u6570\u5b57\u76f8\u5173<\/h5>\n<ul>\n<li>\u6b63\u6574\u6570<code>^[1-9]d*$<\/code><\/li>\n<li>\u8d1f\u6574\u6570 <code>^-[1-9]d*$<\/code><\/li>\n<li>\u6574\u6570 <code>^-?[1-9]d*$<\/code><\/li>\n<li>\u975e\u8d1f\u6574\u6570\uff08\u6b63\u6574\u6570 + 0\uff09 <code>^[1-9]d*|0$<\/code><\/li>\n<li>\u975e\u6b63\u6574\u6570\uff08\u8d1f\u6574\u6570 + 0\uff09 <code>^-[1-9]d*|0$<\/code><\/li>\n<li>\u6b63\u6d6e\u70b9\u6570 <code>^[1-9]d*.d*|0.d*[1-9]d*$<\/code><\/li>\n<li>\u8d1f\u6d6e\u70b9\u6570 <code>^-([1-9]d*.d*|0.d*[1-9]d*)$<\/code><\/li>\n<li>\u6d6e\u70b9\u6570 <code>^-?([1-9]d*.d*|0.d*[1-9]d*|0?.0+|0)$<\/code><\/li>\n<li>\u975e\u8d1f\u6d6e\u70b9\u6570\uff08\u6b63\u6d6e\u70b9\u6570 + 0\uff09 <code>^[1-9]d*.d*|0.d*[1-9]d*|0?.0+|0$<\/code><\/li>\n<li>\u975e\u6b63\u6d6e\u70b9\u6570\uff08\u8d1f\u6d6e\u70b9\u6570 + 0\uff09 <code>^(-([1-9]d*.d*|0.d*[1-9]d*))|0?.0+|0$<\/code><\/li>\n<\/ul>\n<h5>\u683c\u5f0f\u68c0\u67e5<\/h5>\n<ul>\n<li>\u5339\u914d\u4e2d\u6587\u5b57\u7b26 <code>[u4e00-u9fa5]<\/code><\/li>\n<li>\u9650\u5b9a\u53ea\u80fd\u8f93\u5165\u4e2d\u6587\u5b57\u7b26\uff1a<code>^[u4e00-u9fa5],{0,}$<\/code><\/li>\n<li>\u5339\u914dEmail\u5730\u5740\uff1a<code>^w+[-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*$<\/code><\/li>\n<li>\u5339\u914dURL\u5730\u5740\uff1a<code>^http(s):\/\/([w-]+.)+[w-]+(\/[w-.\/?%&amp;=]*)?$<\/code><\/li>\n<li>\u5339\u914d\u56fd\u5185\u7535\u8bdd\u53f7\u7801\uff1a<code>^((d{3,4})|d{3,4}-)?d{7,8}$<\/code><\/li>\n<li>\u5339\u914d\u56fd\u5185\u90ae\u653f\u7f16\u7801\uff1a<code>[1-9]d{5}(?!d)<\/code><\/li>\n<li>\u5339\u914d\u56fd\u5185\u8eab\u4efd\u8bc1\u53f7\uff1a <code>^d{15}|d{18}$<\/code><\/li>\n<li>\u5339\u914d\u9996\u5c3e\u7a7a\u767d\u5b57\u7b26 <code>^s*|s*$<\/code><\/li>\n<li>\u5339\u914dEmail\u5730\u5740 <code>w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*<\/code><\/li>\n<li>\u5339\u914d\u7f51\u5740URL <code>[a-zA-z]+:\/\/[^s]*<\/code><\/li>\n<li>\u5339\u914dip\u5730\u5740\uff1a<code>d+.d+.d+.d+<\/code><\/li>\n<\/ul>\n<h5>RegularExpressionValidator\u8868\u5355\u9a8c\u8bc1<\/h5>\n<ul>\n<li>\u53ea\u80fd\u8f93\u5165\u6570\u5b57\uff1a<code>^[0-9]*$<\/code><\/li>\n<li>\u53ea\u80fd\u8f93\u5165n\u4f4d\u7684\u6570\u5b57\uff1a<code>^d{n}$<\/code><\/li>\n<li>\u53ea\u80fd\u8f93\u5165\u81f3\u5c11n\u4f4d\u6570\u5b57\uff1a<code>^d{n,}$<\/code><\/li>\n<li>\u53ea\u80fd\u8f93\u5165m-n\u4f4d\u7684\u6570\u5b57\uff1a<code>^d{m,n}$<\/code><\/li>\n<li>\u53ea\u80fd\u8f93\u5165\u96f6\u548c\u975e\u96f6\u5f00\u5934\u7684\u6570\u5b57\uff1a<code>^(0|[1-9][0-9]*)$<\/code><\/li>\n<li>\u53ea\u80fd\u8f93\u5165\u6709\u4e24\u4f4d\u5c0f\u6570\u7684\u6b63\u5b9e\u6570\uff1a<code>^[0-9]+(.[0-9]{2})?$<\/code><\/li>\n<li>\u53ea\u80fd\u8f93\u5165\u67091-3\u4f4d\u5c0f\u6570\u7684\u6b63\u5b9e\u6570\uff1a<code>^[0-9]+(.[0-9]{1,3})?$<\/code><\/li>\n<li>\u53ea\u80fd\u8f93\u5165\u975e\u96f6\u7684\u6b63\u6574\u6570\uff1a<code>^+?[1-9][0-9]*$<\/code><\/li>\n<li>\u53ea\u80fd\u8f93\u5165\u975e\u96f6\u7684\u8d1f\u6574\u6570\uff1a<code>^-[1-9][0-9]*$<\/code><\/li>\n<li>\u53ea\u80fd\u8f93\u5165\u957f\u5ea6\u4e3a3\u7684\u5b57\u7b26\uff1a<code>^.{3}$<\/code><\/li>\n<li>\u53ea\u80fd\u8f93\u5165\u753126\u4e2a\u82f1\u6587\u5b57\u6bcd\u7ec4\u6210\u7684\u5b57\u7b26\u4e32\uff1a<code>^[A-Za-z]+$<\/code><\/li>\n<li>\u53ea\u80fd\u8f93\u5165\u753126\u4e2a\u5927\u5199\u82f1\u6587\u5b57\u6bcd\u7ec4\u6210\u7684\u5b57\u7b26\u4e32\uff1a<code>^[A-Z]+$<\/code><\/li>\n<li>\u53ea\u80fd\u8f93\u5165\u753126\u4e2a\u5c0f\u5199\u82f1\u6587\u5b57\u6bcd\u7ec4\u6210\u7684\u5b57\u7b26\u4e32\uff1a<code>^[a-z]+$<\/code><\/li>\n<li>\u53ea\u80fd\u8f93\u5165\u7531\u6570\u5b57\u548c26\u4e2a\u82f1\u6587\u5b57\u6bcd\u7ec4\u6210\u7684\u5b57\u7b26\u4e32\uff1a<code>^[A-Za-z0-9]+$<\/code><\/li>\n<li>\u53ea\u80fd\u8f93\u5165\u7531\u6570\u5b57\u300126\u4e2a\u82f1\u6587\u5b57\u6bcd\u6216\u8005\u4e0b\u5212\u7ebf\u7ec4\u6210\u7684\u5b57\u7b26\u4e32\uff1a<code>^w+$<\/code><\/li>\n<li>\u5339\u914d\u5e10\u53f7\u662f\u5426\u5408\u6cd5(\u5b57\u6bcd\u5f00\u5934\uff0c\u5141\u8bb85-16\u5b57\u8282\uff0c\u5141\u8bb8\u5b57\u6bcd\u6570\u5b57\u4e0b\u5212\u7ebf)\uff1a<code>^[a-zA-Z][a-zA-Z0-9_]{4,15}$<\/code><\/li>\n<li>\u9a8c\u8bc1\u6708\u6570\uff1a<code>^(0?[1-9]|1[0-2])$<\/code>\u6b63\u786e\u683c\u5f0f\u4e3a\uff1a\u201c01\u201d-\u201c09\u201d\u548c\u201c1\u201d\u201c12\u201d<\/li>\n<li>\u9a8c\u8bc1\u5929\u6570\uff1a<code>^((0?[1-9])|((1|2)[0-9])|30|31)$<\/code><\/li>\n<\/ul>\n<h4>\u5728vim\u4e2d\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f<\/h4>\n<p>\u57fa\u672c\u8868\u8fbe\u5f0f: <code>[range]s\/from\/to\/[flags]<\/code><\/p>\n<ul>\n<li>range:\u641c\u7d22\u8303\u56f4\uff0c\u5982\u679c\u6ca1\u6709\u6307\u5b9a\u8303\u56f4\uff0c\u5219\u4f5c\u7528\u4e8e\u5f53\u524d\u884c\u3002<\/li>\n<\/ul>\n<pre><code>:1,10s\/from\/to\/ \u8868\u793a\u5728\u7b2c1\u5230\u7b2c10\u884c\uff08\u5305\u542b\u7b2c1\uff0c\u7b2c10\u884c\uff09\u4e4b\u95f4\u641c\u7d22\u66ff\u6362\uff1b\n:10s\/from\/to\/ \u8868\u793a\u53ea\u5728\u7b2c10\u884c\u641c\u7d22\u66ff\u6362\uff1b\n:%s\/from\/to\/ \u8868\u793a\u5728\u6240\u6709\u884c\u4e2d\u641c\u7d22\u66ff\u6362\uff1b\n:1,$s\/from\/to\/ \u540c\u4e0a\u3002<\/code><\/pre>\n<ul>\n<li>flags \u6709\u5982\u4e0b\u56db\u4e2a\u9009\u9879<\/li>\n<\/ul>\n<pre><code>c confirm\uff0c\u6bcf\u6b21\u66ff\u6362\u524d\u8be2\u95ee\uff1b\ne error\uff0c \u4e0d\u663e\u793a\u9519\u8bef\uff1b\ng global\uff0c\u4e0d\u8be2\u95ee\uff0c\u6574\u884c\u66ff\u6362\u3002\u5982\u679c\u4e0d\u52a0g\u9009\u9879\uff0c\u5219\u53ea\u66ff\u6362\u6bcf\u884c\u7684\u7b2c\u4e00\u4e2a\u5339\u914d\u5230\u7684\u5b57\u7b26\u4e32\uff1b\ni ignore\uff0c\u5ffd\u7565\u5927\u5c0f\u5199\u3002<\/code><\/pre>\n<h5>\u4f8b\u5b50<\/h5>\n<ol>\n<li>\u5c06foo(a,b,c) \u6539\u4e3afoo(b,a,c)<br \/>\n<code>:%s\/foo(([^,]*),([^,]*),([^)]*))\/foo(2,1,3)\/g<\/code><\/li>\n<li>\u5c06abcdef abcedg \u90fd\u66ff\u6362\u4e3a abc asd<br \/>\n<code>:%s\/abc.*\/abc asd\/g<\/code><\/li>\n<li>\u5220\u9664\u4ee5\u6570\u5b57\u5f00\u5934\u7684\u884c<br \/>\n<code>%s\/^d.*$\/\/g<\/code><\/li>\n<li>\u5220\u9664\u4ee5[a,b,c]\u5f00\u5934\u7684\u884c<br \/>\n<code>:%s\/^[a|b|c].*$\/\/g<\/code><\/li>\n<li>\u66ff\u6362windows\u6362\u884c\u7b26<br \/>\n<code>:%s\/&lt;c-v&gt;&lt;c-m&gt;\/\/g<\/code><\/li>\n<li>\u5c06url\u66ff\u6362\u4e3ahtml\u94fe\u63a5<br \/>\n<code>:s\/(http:\/\/[-a-z._~+%\/]+)\/&lt;a href=\"1\"&gt;1&lt;\/a&gt;\/<\/code><\/li>\n<li>\u5c06\u5404\u884c\u7684 id \u5b57\u7b26\u4e32\u66ff\u6362\u4e3a\u884c\u53f7<br \/>\nid 123<br \/>\nid 456<br \/>\n<code>:%s\/&lt;id&gt;\/=line(\".\")<\/code><\/li>\n<li>\u5c06\u591a\u4e2a\u7a7a\u683c\u66ff\u6362\u4e3a1\u4e2a<br \/>\n<code>:%s\/ *\/ \/g<\/code><\/li>\n<li>\u5220\u9664\u884c\u5c3e\u7a7a\u683c<br \/>\n<code>:%s\/ *$\/\/g<\/code><\/li>\n<li>\u5220\u9664\u884c\u9996\u7a7a\u683c<br \/>\n<code>:%s\/^ *\/\/g<\/code><\/li>\n<li>\u5220\u9664\u6240\u6709\u7a7a\u767d\u884c<br \/>\n<code>:g\/^s*$\/d<\/code><\/li>\n<li>\u5220\u9664\u6240\u6709\u51fa\u73b0\u6709string\u7684\u884c<br \/>\n<code>:g\/string\/d<\/code><\/li>\n<li>\u5220\u9664\u6240\u6709\u4e0d\u5305\u542bstring\u7684\u884c<br \/>\n<code>:v\/string\/d<\/code><\/li>\n<li>\u5220\u9664\u6240\u6709HTMl\u6807\u7b7e\uff0c\u4fdd\u7559\u6587\u672c<br \/>\n<code>:%s#&lt;{FNXX==XXFN}+&gt;##g<\/code><\/li>\n<li>\u5220\u9664\u91cd\u590d\u884c<br \/>\n<code>:%s\/^(.*)n1$\/1\/g<\/code><\/li>\n<li>\u6bcf\u884c\u5f00\u5934\u52a0\u4e00\u4e2a\u7a7a\u683c<br \/>\n<code>:%s\/^\/ \/g<\/code><\/li>\n<li>\u4fee\u6539\u9519\u8bef\u62fc\u5199\uff0c\u4f8b\u5982\u6587\u672c\u4e2d\u51fa\u73b0\u4e86beg,bssg,big\u90fd\u66ff\u6362\u6210bug<br \/>\n<code>:%s\/b[e|s|i].*g\/bug\/g<\/code><\/li>\n<li>\u6279\u91cf\u6dfb\u52a0\u6ce8\u91ca<br \/>\n<code>:%s\/^\/#\/<\/code>\u6bcf\u884c\u5f00\u5934\u6dfb\u52a0#\u53f7<br \/>\n<code>:3,10s\/^\/#\/<\/code> 3-10\u884c\u6bcf\u884c\u5f00\u5934\u6dfb\u52a0#\u53f7<\/li>\n<\/ol>\n<p><span style=\"color: #ff0000;\"><strong>\u539f\u6587\u5730\u5740\uff1a<\/strong><\/span><a href=\"http:\/\/www.jianshu.com\/p\/a66fc32bb879\" target=\"_blank\">\u6709\u6548\u4f7f\u7528vim\u4e4b\u6b63\u5219\u8868\u8fbe\u5f0f<\/a><\/p>\n<hr \/>\n<ul>\n<li>\n<h6>\u00a0Vim\u4e2d\u7684\u6807\u8bb0<\/h6>\n<\/li>\n<\/ul>\n<p>\u6807\u8bb0\u53c8\u79f0\u4e3a\u4e66\u7b7e\uff0c\u5728\u67d0\u4e2a\u4f4d\u7f6e\u6253\u4e0a\u6807\u8bb0\u540e\uff0c\u5728\u522b\u5904\u7f16\u8f91\u5b8c\uff0c\u901a\u8fc7\u547d\u4ee4\u53ef\u4ee5\u56de\u5230\u6807\u8bb0\u5904\uff08\u5728\u547d\u4ee4\u6a21\u5f0f\u4e2d\u6267\u884c\uff09<\/p>\n<table>\n<thead>\n<tr>\n<th>\u547d\u4ee4<\/th>\n<th>\u4f5c\u7528<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>mx<\/td>\n<td>\u5c06\u5f53\u524d\u4f4d\u7f6e\u6807\u8bb0\u4e3ax\uff08x\u4e3a26\u4e2a\u5927\u5c0f\u5199\u5b57\u6bcd\u4e2d\u7684\u4efb\u4e00\u4e2a\uff09<\/td>\n<\/tr>\n<tr>\n<td>&#8216;x<\/td>\n<td>\uff08\u5355\u5f15\u53f7\uff09\u53ea\u79fb\u5230\u6807\u8bb0\u6240\u5728\u884c\u7684<em>\u884c\u9996<\/em><\/td>\n<\/tr>\n<tr>\n<td>`x<\/td>\n<td>\uff08\u53cd\u5f15\u53f7\uff09\u8df3\u8f6c\u5230\u6807\u8bb0\u6240\u5728<em>\u884c\u5217<\/em>\u4f4d\u7f6e<\/td>\n<\/tr>\n<tr>\n<td>&#8220;<\/td>\n<td>\uff08\u53cc\u53cd\u5f15\u53f7\uff09\u6765\u56de\u5207\u6362<\/td>\n<\/tr>\n<tr>\n<td>&#8221;<\/td>\n<td>\uff08\u53cc\u5355\u5f15\u53f7\uff09\u6765\u56de\u5207\u6362<\/td>\n<\/tr>\n<tr>\n<td><code>:marks<\/code><\/td>\n<td>\u53d6\u5f97\u6240\u6709\u7684\u6807\u8bb0\u7684\u5217\u8868\uff0cvim\u81ea\u8eab\u7684\u8bb0\u5f55\u4e5f\u4f1a\u5305\u542b\u5728\u5185<\/td>\n<\/tr>\n<tr>\n<td><code>:delmarks x<\/code><\/td>\n<td>\u5220\u9664\u6307\u5b9a\u6807\u8bb0<\/td>\n<\/tr>\n<tr>\n<td><code>:delmarks!<\/code><\/td>\n<td>\u5220\u9664\u6240\u6709\u6807\u8bb0<\/td>\n<\/tr>\n<tr>\n<td>visualmark.vim<\/td>\n<td>\u8be5\u63d2\u4ef6\u53ef\u5b9e\u73b0\u6807\u8bb0\u529f\u80fd\uff0c\u4e14\u6807\u8bb0\u53ef\u89c1<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<ul>\n<li>\n<h6>\u5217\u7f16\u8f91<\/h6>\n<\/li>\n<\/ul>\n<table>\n<thead>\n<tr>\n<th>\u547d\u4ee4<\/th>\n<th>\u4f5c\u7528<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>&lt;c-v&gt;<\/code><\/td>\n<td>ctrl-v \u8fdb\u5165VISUAL BLOCK\u6a21\u5f0f\uff0c\u5373\u5217\u7f16\u8f91<\/td>\n<\/tr>\n<tr>\n<td><code>&lt;c-v&gt; 1h3j<\/code><\/td>\n<td>\u9009\u4e2d\u4e24\u5217\u4e09\u884c<\/td>\n<\/tr>\n<tr>\n<td><code>&lt;c-v&gt; d<\/code><\/td>\n<td>\u5220\u9664\u9009\u4e2d\u7684\u5217<\/td>\n<\/tr>\n<tr>\n<td><code>&lt;c-v&gt; c &lt;esc&gt;<\/code><\/td>\n<td>\u7f16\u8f91\u9009\u4e2d\u7684\u5217\uff0c\u6309ESC\u540e\u751f\u6548<\/td>\n<\/tr>\n<tr>\n<td><code>&lt;c-v&gt; A; &lt;esc&gt;<\/code><\/td>\n<td>\u5728\u9009\u4e2d\u7684\u5217\u540e\u63d2\u5165;\uff0c\u6309ESC\u540e\u751f\u6548<\/td>\n<\/tr>\n<tr>\n<td><code>&lt;c-v&gt; I\/\/ &lt;esc&gt;<\/code><\/td>\n<td>\u5728\u9009\u4e2d\u7684\u5217\u884c\u9996\u63d2\u5165\/\/\uff0c\u6309ESC\u540e\u751f\u6548<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<ul>\n<li>\n<h6>\u7f29\u8fdb<\/h6>\n<\/li>\n<\/ul>\n<table>\n<thead>\n<tr>\n<th>\u547d\u4ee4<\/th>\n<th>\u4f5c\u7528<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>&gt;&gt;<\/code><\/td>\n<td>normal\/visual\u6a21\u5f0f\u4e0b\uff0c\u5f53\u524d\u884c\u589e\u52a0\u7f29\u8fdb<\/td>\n<\/tr>\n<tr>\n<td><code>&lt;&lt;<\/code><\/td>\n<td>normal\/visual\u6a21\u5f0f\u4e0b\uff0c\u5f53\u524d\u884c\u51cf\u5c11\u7f29\u8fdb<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #ff0000;\"><strong>\u53c2\u8003\u94fe\u63a5\uff1a<\/strong><\/span><a href=\"http:\/\/www.jianshu.com\/p\/3327e46421ae\" target=\"_blank\">\u6709\u6548\u4f7f\u7528Vim\u4e4b\u4f7f\u7528\u6280\u5de7<\/a><\/p>\n<p><span style=\"color: #ff0000;\"><strong>\u6269\u5c55\u94fe\u63a5\uff1a<\/strong><\/span><a href=\"http:\/\/www.jianshu.com\/p\/bcbe916f97e1\" target=\"_blank\">Vim\u5165\u95e8\u57fa\u7840<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u597d\u4e45\u6ca1\u6709\u66f4\u65b0\u548cVim\u76f8\u5173\u7684\u5185\u5bb9\u4e86\uff0c\u4e00\u65b9\u9762\u662f\u4e4b\u524d\u6536\u96c6\u7684\u4e00\u4e9b\u6280\u5de7\u5df2\u7ecf\u591f\u7528\u4e86\uff0880\/20\u539f\u5219\uff09\uff0c\u53e6\u4e00\u65b9\u9762\u662f\u56e0\u4e3a\u81ea\u5df1\u8ba4 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,11,12],"tags":[43],"class_list":["post-1380","post","type-post","status-publish","format-standard","hentry","category-knowledgebase-2","category-linux","category-tools","tag-vim"],"views":3172,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/1380","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=1380"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/1380\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=1380"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=1380"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=1380"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}