สืบเนื่องจากเมื่อวานคุณ [T]iD มาคอมเม้นต์ไว้ว่า "แค่พิมพ์ตัวอักษรเดียวก็ขึ้น list มาโชว์หมด ทั้งชื่อตัวแปร ชื่อคลาส snippet " ทำให้เพิ่งรู้ว่า snippet มันขึ้นมาด้วย...

และย้อนกลับไปเมื่อครั้ง "ว่าด้วยเรื่องของ Code Snippets ใน VB 2005 Express (แถม VC# ด้วย)" ผมก็ได้บอกไปว่า VC# 2005 มี Code Snippet ที่เป็นคำสั่งพื้นฐานพวกที่มีลักษณะเป็น Block ด้วย ซึ่งถ้าเจ้าคุณสมบัติ IntelliSense Complete Word list (เรียกซะเต็มยศ) มันสามารถกดใช้จากคีย์บอร์ดได้ล่ะก็ คนเกลียดปีกกาอย่างผมจะคล่องตัวขึ้นเยอะ!! (เพราะไม่ต้องพิมพ์ปีกกาเองอีกต่อไป)

ก็ลองเลย พิมพ์ f o r เอ้ามี list ขึ้นมาแล้ว มี snippet ของ for ให้เลือกจริง ๆ ด้วย มัน highlight ให้แล้ว... กด ENTER ทันที!!!

for

ไหงขึ้น for มาตัวเดียว ..เอาใหม่ พิมพ์ f o r เอ้ามี list ขึ้นมาแล้ว กด TAB ทันที!!!

for

อะไรฟระ! ..อีกที พิมพ์ f o r แล้ว list ก็ขึ้นมา กด SPACE BAR ทันที!!!

for

ฮึ่ย~ ทำไมไม่ได้ล่ะเนี่ย!! ก็เลยลองไปหาใน MSDN Express ... ก็เจอ

To use code snippets through the IntelliSense Complete Word list
  1. In the Visual Studio IDE, open the file that you intend to edit.
  2. In the Code Editor, place the cursor where you would like to insert the code snippet.
  3. Begin typing the shortcut for the code snippet that you want to add to your code. If automatic completion is turned on, then the IntelliSense complete word list will be displayed. If it does not appear, then press CTRL+SPACE to activate it.
  4. Select the code snippet from the complete word list.
  5. Type TAB, TAB to invoke the code snippet.

กด TAB สองทีงั้นหรือ? เอาลองใหม่ พิมพ์ f o r แล้ว list ก็ขึ้นมา กด TAB .... list หายไปตามเคย งั้น.. กด TAB อีกที!!!

for (int i = 0; i < length; i++)
{
 
}

สวยงามมาก.... ในที่สุดเราก็ไม่ต้องพิมพ์ปีกกาเองแล้ว!!!

อ้อ แถม สำหรับ Surround With
  1. เลือกข้อความที่จะล้อมกรอบซะก่อน
  2. กด CTRL+K แล้วตามด้วย CTRL+S จะมี list ของ snippet มาให้เลือก
  3. กดลูกศรเลื่อนเอาแล้วเลือกด้วย TAB หรือ ENTER จบ.
ถ้าลองแล้วจะพบว่า CTRL+K แล้วตามด้วย CTRL+S มันคือ Shortcut สำหรับเรียก Code Snippet นั่นเอง...

edit @ 2007/09/04 15:55:59
edit @ 2007/09/04 16:06:05
edit @ 2007/09/04 16:20:26

Comment



smilebig smileopen-mounthed smileconfused smilesad smileangry smiletonguequestionembarrassedsurprised smilewinkdouble winkcry

Tweet

ไอ้ Tab สองที กับ Tab ทีเดียวใน VB นี่ก็เป็นอะไรที่ฮาอีกอย่าง
ide สองตัวทำไม่เหมือนกันซะ

#1 By T!D on 2007-09-05 09:32

ไอ้ Tab สองที กับ Tab ทีเดียวใน VB นี่ก็เป็นอะไรที่ฮาอีกอย่าง
ide สองตัวทำไม่เหมือนกันซะ

#2 By T!D on 2007-09-05 09:32

NinkungZ View my profile


Favourites


View My Stats