This is G o o g l e's cache of http://www.debianclub.com/node/81 as retrieved on 15 Feb 2007 15:22:38 GMT.
G o o g l e's cache is the snapshot that we took of the page as we crawled the web.
The page may have changed since that time. Click here for the current page without highlighting.
This cached page may reference images which are no longer available. Click here for the cached text only.
To link to or bookmark this page, use the following url: http://www.google.com/search?hl=en&q=cache%3Ahttp%3A%2F%2Fwww.debianclub.com%2Fnode%2F81&btnG=Search


Google is neither affiliated with the authors of this page nor responsible for its content.

User login

Links

debianclub.com
debian.org
ubuntuclub.com
blognone.com

Syndicate

Syndicate content

เกร็ด vim อีกรอบ

ปกติ vim จะตีความข้อมูลด้วยค่า locale ของเครื่อง เช่น ถ้าตั้งค่า locale เป็น utf-8 ด้วยคำสั่ง

# dpkg-reconfigure locales

แล้วตั้งเป็น th_TH.utf8 เวลาเราเรียกใช้ vim เราจะสามารถใช้งานภาษาไทยที่เข้ารหัสเป็น utf8 ได้โดยทันที

ปัญหาคือ ถ้าเรามีบางไดเรกทอรีที่เข้ารหัสข้อมูลด้วยรหัสอื่น เช่น tis620 เราจะไม่สามารถใช้งานภาษาไทยได้

วิธีแก้คือ

  1. สั่งงาน vim ด้วยตัวแปร env LANG เป็นค่า locale ที่ต้องการ
    # LANG=th_TH.tis620 vim FILENAME
  2. ตั้งค่าตัวแปร encoding เป็น thai
    :set enc=thai
  3. ตั้งค่าตัวแปร termencoding เป็น utf-8
    :set termencoding=utf-8

ด้วยวิธีนี้ เราสามารถแก้ไขไฟล์ที่เข้ารหัสเป็น tis-620 ได้ครับ

หมายเหตุ

ถ้าท่านใดทราบวิธีทำให้เป็นอัตโนมัติผ่าน vimrc รบกวนช่วยเสริมด้วยนะครับ
( ผมหาพบที่ google cache แต่อ่านไม่ค่อยเข้าใจ )

เพิ่มเติม

ที่ codenone มีคุยเรื่อง vimrc ด้วย :)