$vim ~/.vimrc
let &termencoding=&encoding
set fileencodings=utf-8,gbk
$:wq
Ôٴδò¿ªvi£¬ÏÔʾ¾ÍÕý³£ÁË¡£Èç¹û²»Õý³££¬ÖØпªÒ»¸öÖնˣ¬Ôٴδò¿ªvi¡£
¸üÏêϸµÄ×ÊÁÏ£º
vimÖб༲»Í¬±àÂëµÄÎļþʱÐèҪעÒâµÄһЩµØ·½
´ËÎĽ²½âµÄÊÇvim±à¼¶à×Ö½Ú±àÂëÎĵµ£¨ÖÐÎÄ£©ËùÒªÁ˽âµÄһЩ»ù´¡ÖªÊ¶£¬×¢ÒâÆäûÓÐÉæ¼°gvim£¬´¿Ö¸×Ö·ûÖÕ¶ËϵÄvim¡£
vim±àÂë·½ÃæµÄ»ù´¡ÖªÊ¶£º
1£¬´æÔÚ3¸ö±äÁ¿£º
encoding¡ª-¸ÃÑ¡ÏîʹÓÃÓÚ»º³åµÄÎı¾(ÄãÕýÔڱ༵ÄÎļþ)£¬¼Ä´æÆ÷£¬Vim ½Å±¾ÎļþµÈµÈ¡£Äã¿ÉÒÔ°Ñ ¡®encoding¡¯ Ñ¡Ïîµ±×÷ÊÇ¶Ô Vim ÄÚ²¿ÔËÐлúÖƵÄÉ趨¡£
fileencoding¡ª-¸ÃÑ¡ÏîÊÇvimдÈëÎļþʱ²ÉÓõıàÂëÀàÐÍ¡£
termencoding¡ª-¸ÃÑ¡Ïî´ú±íÊä³öµ½¿Í»§Öնˣ¨Term£©²ÉÓõıàÂëÀàÐÍ¡£
2£¬´Ë3¸ö±äÁ¿µÄĬÈÏÖµ£º
encoding¡ª-Óëϵͳµ±Ç°localeÏàͬ£¬ËùÒÔ±à¼ÎļþµÄʱºòÒª¿¼Âǵ±Ç°locale£¬·ñÔòÒªÉèÖõĶ«Î÷¾Í±È½Ï¶àÁË¡£
fileencoding¡ª-vim´ò¿ªÎļþʱ×Ô¶¯±æÈÏÆä±àÂ룬fileencoding¾ÍΪ±æÈϵÄÖµ¡£Îª¿ÕÔò±£´æÎļþʱ²ÉÓÃencodingµÄ±àÂ룬Èç¹ûûÓÐÐÞ¸Äencoding£¬ÄÇÖµ¾ÍÊÇϵͳµ±Ç°localeÁË¡£
termencoding¡ª-ĬÈÏ¿ÕÖµ£¬Ò²¾ÍÊÇÊä³öµ½Öն˲»½øÐбàÂëת»»¡£
Óɴ˿ɼû£¬±à¼²»Í¬±àÂëÎļþÐèҪעÒâµÄµØ·½²»½ö½öÊÇÕâ3¸ö±äÁ¿£¬»¹ÓÐϵͳµ±Ç°localeºÍ¡¢Îļþ±¾Éí±àÂëÒÔ¼°×Ô¶¯±àÂëʶ±ð¡¢¿Í»§ÔËÐÐvimµÄÖÕ¶ËËùʹÓõıàÂëÀàÐÍ3¸ö¹Ø¼üµã£¬Õâ3¸ö¹Ø¼üµãÓ°Ïì×Å3¸ö±äÁ¿µÄÉ趨¡£
Èç¹ûÓÐÈËÎÊ£ºÎªÊ²Ã´ÎÒÓÃvim´ò¿ªÖÐÎÄÎĵµµÄʱºò³öÏÖÂÒÂ룿
´ð°¸ÊDz»È·¶¨µÄ£¬ÔÒòÉÏÃæÒѾ½²ÁË£¬²»¸ãÇå³þÕâ3¸ö¹Ø¼üµãºÍÕâ3¸ö±äÁ¿µÄÉ趨ֵ£¬³öÏÖÂÒÂëÊÇÕý³£µÄ£¬µ¹ÊDz»³öÏÖÂÒÂëÄÇ·´µ¹ÊÇ´ÕÇɵġ£
ÔÙÀ´¿´Ò»Ï³£¼ûÇé¿öÏÂÕâÈý¸ö¹Ø¼üµãµÄÖµÒÔ¼°ÔÚÕâÖÖÇé¿öÏÂÕâ3¸ö±äÁ¿µÄÖµ£º
1£¬locale¡ª-Ä¿Ç°´ó²¿·ÖLinuxϵͳÒѾ½«utf-8×÷ΪĬÈÏlocaleÁË£¬²»¹ýÒ²ÓпÉÄܲ»ÊÇ£¬ÀýÈçÓÐЩϵͳʹÓÃÖÐÎÄlocale zh_CN.GB18030¡£ÔÚlocaleΪutf-8µÄÇé¿öÏ£¬Æô¶¯vimºóencoding½«»áÉèÖÃΪutf-8£¬ÕâÊǼæÈÝÐÔ×îºÃµÄ·½Ê½£¬ÒòΪÄÚ²¿ ´¦ÀíʹÓÃutf-8µÄ»°£¬ÎÞÂÛÍⲿ´æ´¢±àÂëΪºÎ¶¼¿ÉÒÔ½øÐÐÎÞȱËðת»»¡£locale¾ö¶¨ÁËvimÄÚ²¿´¦ÀíÊý¾ÝµÄ±àÂ룬Ҳ¾ÍÊÇencoding¡£
2£¬ÎļþµÄ±àÂëÒÔ¼°×Ô¶¯±àÂëʶ±ð¡ª-Õâ·½ÃæÇ£³¶µ½¸÷ÖÖ±àÂëµÄ¹æÔò£¬¾Í²»Ò»Ò»Ï¸½²ÁË¡£µ«ÐèÒªÃ÷°×µÄÊÇ£¬Îļþ±àÂëÀàÐͲ¢²»ÊDZ£´æÔÚÎļþÄڵģ¬Ò²¾ÍÊÇ˵ûÓÐÈκΠÃèÊöÐÔµÄ×Ö¶ÎÀ´¼Ç¼ÎĵµÊǺÎÖÖ±àÂëÀàÐ͵ġ£Òò´ËÎÒÃÇÔÚ±à¼ÎĵµµÄʱºò£¬ÒªÃ´±ØÐëÖªµÀÕâÎĵµ±£´æʱÊÇÒÔʲô±àÂë±£´æµÄ£¬ÒªÃ´Í¨¹ýÁíÍâµÄһЩÊÖ¶ÎÀ´¶Ï¶¨±àÂëÀà ÐÍ£¬ÕâÁíÍâµÄÊֶΣ¬¾ÍÊÇͨ¹ýijЩ±àÂëµÄÂë±íÌØÕ÷À´¶Ï¶¨£¬ÀýÈçÿ¸ö×Ö·ûÕ¼ÓõÄ×Ö½ÚÊý£¬Ã¿¸ö×Ö·ûµÄasciiÖµÊÇ·ñ¶¼´óÓÚij¸ö×Ö¶ÎÀ´¶Ï¶¨Õâ¸öÎļþÊôÓÚºÎÖÖ±à Âë¡£ÕâÖÖ·½Ê½vimҲʹÓÃÁË£¬Õâ¾ÍÊÇvimµÄ×Ô¶¯±àÂëʶ±ð»úÖÆÁË¡£µ«ÕâÖÖ»úÖÆÓÉÓÚ±àÂë¸÷ʽ¸÷Ñù£¬²»¿ÉÄÜÿÖÖ±àÂ붼ÓÐÏÔÖøµÄÌØÕ÷À´±æ±ð£¬ËùÒÔÊDz»¿ÉÄÜ 100%׼ȷµÄ¡£¶ÔÓÚÎÒÃÇGB2312±àÂ룬ÓÉÓÚÆäÖÐÎÄÊÇʹÓÃÁË2¸öacsiiÖµ¸ßÓÚ127µÄ×Ö·û×é³Éºº×Ö×Ö·ûµÄ£¬Òò´Ë²»¿ÉÄÜ°Ñgb2312±àÂëµÄÎļþÓë latin1±àÂëÇø·Ö¿ªÀ´£¬Òò´Ë×Ô¶¯Ê¶±ð±àÂëµÄ»úÖƶÔÓÚgb2312ÊDz»³É¹¦µÄ£¬ËüÖ»»á½«Îļþ±æʶΪlatin1±àÂë¡£´ËÎÊÌâͬÑù³öÏÖÔÚgbk£¬big5 Éϵȡ£Òò´ËÎÒÃÇÔڱ༴ËÀàÎĵµÊ±£¬ÐèÒªÊÖ¹¤É趨encodingºÍfileencoding¡£Èç¹ûÎĵµ±àÂëΪutf-8ʱ£¬Ò»°ãvim¶¼ÄÜ×Ô¶¯Ê¶±ðÕýÈ·µÄ ±àÂë¡£
3£¬¿Í»§ÔËÐÐvimµÄÖÕ¶ËËùʹÓõıàÂëÀàÐÍ¡ª-ͬµÚ¶þÌõÒ»Ñù£¬ÕâÒ²ÊÇÒ»¸ö±È½ÏÄÑÒԶ϶¨µÄ¹Ø¼üµã¡£µÚ¶þ¸ö¹Ø¼üµã¾ö¶¨×Å´ÓÎļþ¶ÁÈ¡ÄÚÈݺÍдÈëÄÚÈݵ½Îļþ ʱʹÓõıàÂ룬¶ø´Ë¹Ø¼üµãÔò¾ö¶¨vimÊä³öÄÚÈݵ½ÖÕ¶ËʱʹÓõıàÂ룬Èç¹û´Ë±àÂëÀàÐͺÍÖÕ¶ËÈÏΪËüÊÕµ½µÄÊý¾ÝµÄ±àÂëÀàÐͲ»Í¬£¬ÔòÓÖ»á²úÉúÂÒÂëÎÊÌâ¡£ÔÚ linux±¾µØX»·¾³Ï£¬Ò»°ãÖն˶¼ÈÏΪÆä½ÓÊÕµÄÊý¾ÝµÄ±àÂëÀàÐͺÍϵͳlocaleÀàÐÍÏà·û£¬Òò´Ë²»Ðè¹ØÐÄ´Ë·½ÃæÊÇ·ñ´æÔÚÎÊÌâ¡£µ«Èç¹ûÇ£Éæµ½Ô¶³ÌÖնˣ¬Àý ÈçsshµÇ¼·þÎñÆ÷£¬ÔòÎÊÌâ¾ÍÓпÉÄܳöÏÖÁË¡£ÀýÈç´Ó1̨localeΪGB2310µÄϵͳ£¨³Æ×÷¿Í»§»ú£©sshµ½localeΪutf-8µÄϵͳ£¨³Æ×÷·þ ÎñÆ÷£©²¢¿ªÆôvim±à¼Îĵµ£¬ÔÚ²»¼ÓÈκθĶ¯µÄÇé¿öÏ£¬·þÎñÆ÷·µ»ØµÄÊý¾ÝΪutf-8µÄ£¬µ«¿Í»§»úÈÏΪ·þÎñÆ÷·µ»ØµÄÊý¾ÝÊÇgb2312µÄ£¬°´ÕÕ gb2312À´½âÊÍÊý¾Ý£¬Ôò¿Ï¶¨¾ÍÊÇÂÒÂëÁË£¬Õâʱ¾ÍÐèÒªÉèÖÃtermencodingΪgb2312À´½â¾öÕâ¸öÎÊÌâ¡£´ËÎÊÌâ¸ü¶à³öÏÖÔÚÎÒÃÇµÄ windows desktop»úÔ¶³ÌsshµÇ¼·þÎñÆ÷µÄÇé¿öÏ£¬ÕâÀïÇ£³¶µ½²»Í¬ÏµÍ³µÄ±àÂëת»»ÎÊÌâ¡£ËùÒÔÓÖÓëwindows±¾ÉíÒÔ¼°ssh¿Í»§¶ËÓкܴóÏà¹ØÐÔ¡£ÔÚ windowsÏ´æÔÚÁ½ÖÖ±àÂëÀàÐ͵ÄÈí¼þ£¬Ò»ÖÖÊDZ¾Éí¾ÍΪunicode±àÂ뷽ʽ±àдµÄÈí¼þ£¬Ò»ÖÖÊÇansiÈí¼þ£¬Ò²¾ÍÊdzÌÐò´¦ÀíÊý¾ÝÖ±½Ó²ÉÓÃ×Ö½ÚÁ÷£¬²» ¹ØÐıàÂ롣ǰһÖÖ³ÌÐò¿ÉÒÔÔÚÈκÎÓïÑÔµÄwindowsÉÏÕýÈ·ÏÔʾ¶à¹úÓïÑÔ£¬¶øºóÒ»ÖÖÔò±àдÔÚºÎÖÖÓïÑÔµÄϵͳÉÏÔòÖ»ÄÜÔÚºÎÖÖÓïÑÔµÄϵͳÉÏÏÔʾÕýÈ·µÄÎÄ×Ö¡£¶Ô ÓÚÕâÁ½ÖÖÀàÐ͵ijÌÐò£¬ÎÒÃÇÐèÒªÇø±ð¶Ô´ý¡£ÒÔssh¿Í»§¶ËΪÀý£¬ÎÒÃÇʹÓõÄputtyÊÇunicodeÈí¼þ£¬¶øsecure CRTÔòÊÇansi Èí¼þ¡£¶ÔÓÚÇ°Õߣ¬ÎÒÃÇÒªÕýÈ·´¦ÀíÖÐÎÄ£¬Ö»Òª±£Ö¤vimÊä³öµ½Öն˵ıàÂëΪutf-8¼´¿É£¬¾ÍÊÇtermencoding=utf-8¡£µ«¶ÔÓÚºóÕߣ¬Ò»·½Ãæ ÎÒÃÇҪȷÈÏÎÒÃǵÄwindowsϵͳĬÈÏ´úÂëҳΪcp936£¨ÖÐÎÄwindowsĬÈÏÖµ£©£¬ÁíÒ»·½ÃæҪȷÈÏvimÉèÖõÄtermencoding= cp936¡£
×îºóÀ´¿´¿´´¦ÀíÖÐÎÄÎĵµ×îµäÐ͵ļ¸ÖÖÇé¿öºÍÉèÖ÷½Ê½£º
1£¬ÏµÍ³localeÊÇutf-8£¨ºÜ¶àlinuxϵͳĬÈϵÄlocaleÐÎʽ£©£¬±à¼µÄÎĵµÊÇGB2312»òGBKÐÎʽµÄ£¨Windows¼Çʱ¾ ĬÈϱ£´æÐÎʽ£¬´ó²¿·Ö±à¼Æ÷ҲĬÈϱ£´æΪÕâ¸öÐÎʽ£¬ËùÒÔ×î³£¼û£©£¬ÖÕ¶ËÀàÐÍutf-8£¨Ò²¾ÍÊǼٶ¨¿Í»§¶ËÊÇputtyÀàµÄunicodeÈí¼þ£©
Ôòvim´ò¿ªÎĵµºó£¬encoding=utf-8£¨locale¾ö¶¨µÄ£©£¬fileencoding=latin1£¨×Ô¶¯±àÂëÅжϻúÖƲ»×¼µ¼Öµģ©£¬termencoding=¿Õ£¨Ä¬ÈÏÎÞÐèת»»term±àÂ룩£¬ÏÔʾÎļþΪÂÒÂë¡£
½â¾ö·½°¸1£ºÊ×ÏÈÒªÐÞÕýfileencodingΪcp936»òÕßeuc-cn£¨¶þÕßÒ»ÑùµÄ£¬Ö»²»¹ý½Ð·¨²»Í¬£©£¬×¢ÒâÐÞÕýµÄ·½·¨²»ÊÇ:set fileencoding=cp936£¬ÕâÖ»Êǽ«Îļþ±£´æΪcp936£¬ÕýÈ·µÄ·½·¨ÊÇÖØÐÂÒÔcp936µÄ±àÂ뷽ʽ¼ÓÔØÎļþΪ:edit ++enc=cp936£¬¿ÉÒÔ¼òдΪ:e ++enc=cp936¡£
½â¾ö·½°¸2£ºÁÙʱ¸Ä±ävimÔËÐеÄlocale»·¾³£¬·½·¨ÊÇÒÔLANG=zh_CN vim abc.txtµÄ·½Ê½À´Æô¶¯vim£¬Ôò´Ëʱencoding=euc-cn£¨locale¾ö¶¨µÄ£©£¬fileencoding=¿Õ£¨´ËlocaleÏÂÎļþ ±àÂë×Ô¶¯Åбð¹¦Äܲ»ÆôÓã¬ËùÒÔfileencodingΪÎļþ±¾Éí±àÂ뷽ʽ²»±ä£¬Ò²¾ÍÊÇeuc-cn£©£¬termencoding=¿Õ£¨Ä¬ÈÏÖµ£¬Îª¿ÕÔòµÈ ÓÚencoding£©´Ëʱ»¹ÊÇÂÒÂëµÄ£¬ÒòΪÎÒÃǵÄsshÖÕ¶ËÈÏΪ½ÓÊܵÄÊý¾ÝΪutf-8£¬µ«vim·¢ËÍÊý¾ÝΪeuc-cn£¬ËùÒÔ»¹ÊDz»¶Ô¡£´ËʱÔÙÓÃÃüÁî: set termencoding=utf-8½«ÖÕ¶ËÊý¾ÝÊä³öΪutf-8£¬ÔòÏÔʾÕý³£¡£
2£¬Çé¿öÓë1»ù±¾Ïàͬ£¬Ö»ÊÇʹÓõÄsshÈí¼þΪsecure CRTÀàansiÀàÈí¼þ¡£
vim´ò¿ªÎĵµºó£¬encoding=utf-8£¨locale¾ö¶¨µÄ£©£¬fileencoding=latin1£¨×Ô¶¯±àÂëÅжϻúÖƲ»×¼µ¼Öµģ©£¬termencoding=¿Õ£¨Ä¬ÈÏÎÞÐèת»»term±àÂ룩£¬ÏÔʾÎļþΪÂÒÂë¡£
½â¾ö·½°¸1£ºÊ×ÏÈÒª±£Ö¤ÔËÐÐsecure CRTµÄwindows»úÆ÷µÄĬÈÏ´úÂëҳΪCP936£¬ÕâÒ»µãÖÐÎÄwindowsÒѾÊÇĬÈÏÉèÖÃÁË¡£ÆäËûµÄÓëÉÏÃæ·½°¸1Ïàͬ£¬Ö»ÊÇÒªÔö¼ÓÒ»²½£¬:set termencoding=cp936
½â¾ö·½°¸2£ºÓëÉÏÃæ·½°¸2ÀàËÆ£¬²»¹ý×îºóÒ»²½ÐÞ¸ÄtermencodingÊ¡ÂÔ¼´¿É£¬ÔÚ´ËÇé¿öÏÂÐèÒªµÄÐÞ¸Ä×îÉÙ£¬Ö»ÒªÒÔlocaleΪzh_CN¿ª Æôvim£¬Ôòencoding=euc-cn£¬fileencodingºÍtermencoding¶¼Îª¿Õ¼´ÎªencodingµÄÖµ£¬ÊÇ×îÀíÏëµÄÒ»ÖÖÇé ¿ö¡£
¿É¼ûÀí½âÕâ3¸ö¹Ø¼üµãºÍ3¸ö²ÎÊýµÄÒâÒ壬¶ÔÓÚ±àÂëÎÊÌâÓкܴóÖúÁ¦£¬ÒÔºó¾Í¿ÉÒÔËæÐÄËùÓûµÄ´¦ÀíÎĵµÁË£¬Í¬Ê±²»½ö½öÊÇÓ¦ÓÃÓÚvim£¬ÔÚÆäËûÐèÒª±àÂëת»»µÄ»·¾³À¶¼¿ÉÒÔÓ¦ÓÃÀàËƵÄ˼·À´´¦ÀíÎÊÌâ½â¾öÎÊÌâ¡£
×îºóÍƼöÒ»¿î¹¦ÄÜÇ¿´óµÄwindowsϵÄssh¿Í»§¶Ë¡ª-xshell£¬Ëü¾ßÓÐÀàËÆsecure CRTÒ»ÑùµÄ¶àtab µÄssh´°¿ÚµÄÄÜÁ¦£¬µ«×îΪ·½±ãµÄÊÇÕâ¿î¹¤¾ß»¹ÓиıäTerm±àÂëµÄ¹¦ÄÜ£¬ÕâÑùÎÒÃǾͿÉÒÔ²»ÓÃƵ·±µ÷Õûtermencoding£¬Ö»ÐèÔÚsshÈí¼þÀïÇл» ±àÂë¼´¿É£¬ÕâÊÇÎÒÓùýµÄ×îΪ·½±ãµÄssh¹¤¾ß¡£ËüÊÇÉÌÒµÈí¼þ£¬µ«·Ç×¢²áÓû§Ê¹ÓÃûÓÐÈκÎÏÞÖÆ£¬Ö»ÊÇ30ÌìÊÔÓÃÆÚ³¬³öºó»áÿ´ÎÆô¶¯¶¼Ìáʾע²á£¬¶ÔÓÚ¹¦ÄÜûÓÐ Ë¿ºÁÓ°Ïì¡£
ÍƼöÐÅÏ¢
- linuxÃüÁîѧϰ±Ê¼Ç£¨11£©£ºnlÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨5£©£ºrmÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨4£©£ºmkdirÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨1£©£ºlsÃüÁî
- ½«CentosµÄyumÔ´¸ü»»Îª¹úÄڵİ¢ÀïÔÆÔ´
- ʹÓÃNginxÌí¼Óheader·ÀÖ¹ÍøÒ³±»frame
- linuxϼÓËÙscp´«Êä´óÎļþµÄËÙ¶È
- linuxϵͳÉ϶ÔnginxÈÕÖ¾·Ö¸î´¦Àí
- lnmp/nginxϵͳÕæÕýÓÐЧµÄͼƬ·ÀµÁÁ´ÍêÕûÉèÖÃÏê½â
- Í»ÆÆÊ®Íò²¢·¢µÄNginxµÄÅäÖü°ÓÅ»¯
ÈÈÃÅÐÅÏ¢
- nohup: redirecting stderr to stdou....
- ʹÓÃlog_formatΪNginx·þÎñÆ÷ÉèÖøüÏêϸµÄÈÕÖ¾¸ñʽ
- jquery easyUI--dataGrid-Json
- [Ô´´]·ÂGoogle Reader¡¢ÐÂÀË΢²©¡¢ÌÚѶ΢²©µ....
- ÀûÓÃKeepalived+mysql¹¹½¨¸ß¿ÉÓÃMySQLË«Ö÷×Ô¶....
- Nginx+keepalivedʵÏÖ¸ºÔؾùºâºÍË«»úÈȱ¸¸ß¿ÉÓÃ
- jqueryʵÏÖÒ³Ãæ¼ÓÔؽø¶ÈÌõ
- Rolling cURL: PHP²¢·¢×î¼Ñʵ¼ù
- codeigniter ·ÓÉÖÕ¼«ÓÅ»¯(url rewrite)
- linuxÏÂÉèÖÃsshÎÞÃÜÂëµÇ¼
×î½ü¸üÐÂ
- ²éÕÒ²¢É¾³ý.svnĿ¼Îļþ
- redis ÆßÖÖÊý¾ÝÀàÐ͵ÄʹÓó¡¾°
- linux ÏÂÎļþ¸´ÖƵ½windowsÏÂÂÒÂëµÄ½â¾ö°ì·¨
- nginx³öÏÖ502 upstream sent too big he....
- linuxÏÂsudoÅäÖÃÏê½â
- linuxÃüÁîѧϰ±Ê¼Ç£¨15£©£ºtailÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨14£©£ºheadÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨13£©£ºlessÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨12£©£ºmoreÃüÁî
- ¼ÓÃÜËã·¨±È½Ï3DES AES RSA ECC MD5 SHA1µÈ
ÆÀÂÛ