Snippets vs. Abbreviations in Vim

后端 未结 4 1835
再見小時候
再見小時候 2021-02-15 12:40

What advantages and/or disadvantages are there to using a \"snippets\" plugin, e.g. snipmate, ultisnips, for VIM as opposed to simply using the builtin \"abbreviations\"

4条回答
  •  既然无缘
    2021-02-15 13:29

    Snippets

    Rough superset of Vim's native abbreviations. Here are the highlights:

    • Only trigger on key press
    • Uses placeholders which a user can jump between
    • Exist only for insert mode
    • Dynamic expansions

    Abbreviations

    Great for common typos and small snippets.

    • Native to Vim so no need for plugins
    • Typically expand on whitespace or
    • Some special rules on trigger text (See :h abbreviations)
    • Can be used in command mode via :cabbrev (often used to create command aliases)
    • No placeholders
    • Dynamic expansions

    Conclusion

    For the most part snippets are more powerful and provide many features that other editors enjoy, but you can use both and many people do. Abbreviations enjoy the benefit of being native which can be useful for remote environments. Abbreviations also enjoy another clear advantage which is can be used in command mode.

提交回复
热议问题