DEV Community

Weerasak Chongnguluam
Weerasak Chongnguluam

Posted on • Edited on

1

Replace comma with newline in VS Code

ทริกเล็กๆวันนี้คือวิธีที่เราจะแทนที่ , (comma) ไปเป็นการขึ้นบรรทัดใหม่ได้ยังไงใน VS Code

เช่นถ้าเรามีข้อความแบบนี้

1, 2, 3, 4, 5
Enter fullscreen mode Exit fullscreen mode

แล้วอยากเปลี่ยนเป็นแบบนี้

1
2
3
4
5
Enter fullscreen mode Exit fullscreen mode

เราสามารถทำยังไงได้บางใน VS Code

ง่ายๆคือให้เรากด shortcut ในการค้นหาข้อความในไฟล์ สำหรับ macOS กด command + f แล้วจะเจอ dialog เล็กๆแบบนี้

Alt Text

ให้เรากดตรง > ด้านหน้าช่องค้นหา จะเห็นอีกช่องสำหรับใส่คำแทนทีแบบนี้

Alt Text

จากนั้นให้เราใส่ , ในช่อง Find เพื่อค้นหา comma และ space หลัง comma

ทีนี้ตรงช่อง Replace เราจะกด enter เลยไม่ได้เพราะจะเป็นการสั่งให้ replace ทันที แต่ในที่นี้เราอยากใส่ newline เราจะทำได้โดยการกด ctrl + enter คือกด ctrl ค้างไว้แล้วกด enter ตามไปนั่นเอง

Alt Text

จากนั้นก็กด enter อีกทีเพื่อสั่ง replace เราก็จะได้ผลลัพธ์ตามที่ต้องการแล้ว

Buy Me A Coffee

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay