代码片段管理工具
by Sam Williams
通过山姆·威廉姆斯
VS代码片段:提高编码效率的最强大工具 (VS Code snippets: the most powerful tool to boost your coding productivity)
用更少的按键编写更多的代码 (Write more code with fewer keystrokes)
Everyone wants to be able to produce more code in fewer keystrokes. Arrow functions in JavaScript have become incredibly popular recently — and they only save you 6 characters!
每个人都希望能够用更少的按键产生更多的代码。 JavaScript中的箭头功能最近变得非常流行-它们只能为您节省6个字符!
(function(){console.log('a')})() // 32 charachters(()=>{console.log('a')})() // 26 charachters
But there is a better way to save typing — and this article will show you the tool to do it.
但是,有一种更好的保存类型的方法-本文将向您展示实现此目的的工具。
代码段 (Code Snippets)
For years, people have used code snippets to save time — whether they are common functions, file structures or even templates for whole systems. This is not a new idea.
多年以来,人们一直在使用代码段来节省时间-无论它们是通用功能,文件结构,还是整个系统的模板。 这不是一个新的想法。
The problem with a lot of existing systems is that these snippets were often stored in text files or other file systems and needed to be manually copied and pasted into wherever they were needed.
许多现有系统的问题在于,这些代码段通常存储在文本文件或其他文件系统中,需要手动复制并粘贴到所需的位置。
This was great for large snippets of code. But one-liners were often quicker to type than to search for the file, copy it and paste it in.
这对于大型代码片段非常有用。 但是,单行键入通常比搜索文件,复制并粘贴文件更快。
The next step was tools such as TextExpander or AutoHotKeys, where special key sequences could be set up to paste code snippets into wherever you were typing. These are great and can save you loads of time… but we can take it one step further.
下一步是诸如TextExpander或AutoHotKeys之类的工具,可以在其中设置特殊的键序列,以将代码段粘贴到您键入的任何位置。 这些功能很棒,可以节省您的时间...但是我们可以更进一步。