4

有没有办法检查所有可用的 snipMate 片段?像i <c-r><tab>确实一样,但有更多信息?

我很好奇:

  • 它将完成的字符串。
  • 如果可用,请提供带有片段的描述或评论。

一些允许转换为 HTML 的工具会很棒,但在 vim 中的技巧也会很酷:)

4

3 回答 3

6

这可能有帮助,也可能没有帮助,但我整理了一个“ls_snip”shell 脚本,它将列出各种文件类型的片段和任何前面的注释。它没有以任何方式集成到 vim 中,并且依赖于 *nix 操作系统。此外,仅适用于 snippets/filetype.snippets 文件,而不适用于 snippets/filetype/match.snippets 文件。您可以根据自己的喜好从这里破解它。

将它放在某个 PATH 目录中的 ls_snip 中,并使其可执行。

#! /bin/bash
list_snippets_for() {
  egrep "^snippet|^#" ~/.vim/snippets/$1.snippets | awk '/^#/ {comment = comment $0} /^snippet/ {print $0 "\t\t" comment; comment=""}'
}

if [ "$1" == "" ]
then
  echo "You must specify at least one file type as an argument to ls_snip"
  exit
fi

for filetype in "$@"
do
  echo `echo $filetype | awk '{print toupper($0)}'`
  list_snippets_for $filetype
  echo
done

这是一个示例输出

[lwoodson@lwoodson-mint-vb spike] [root@rva-lw] $ ls_snip javascript html
JAVASCRIPT
snippet proto       # Prototype
snippet fun     # Function
snippet f       # Anonymous Function
snippet if      # if
snippet ife     # if ... else
snippet t       # tertiary conditional
snippet switch      # switch
snippet case        # case
snippet for     # for (...) {...}
snippet forr        # for (...) {...} (Improved Native For-Loop)
snippet wh      # while (...) {...}
snippet do      # do...while
snippet :f      # Object Method
snippet timeout     # setTimeout function
snippet get     # Get Elements
snippet gett        # Get Element

HTML
snippet nbs     # Some useful Unicode entities# Non-Breaking Space
snippet left        # ←
snippet right       # →
snippet up      # ↑
snippet down        # ↓
snippet return      # ↩
snippet backtab     # ⇤
snippet tab     # ⇥
snippet shift       # ⇧
snippet control     # ⌃
snippet enter       # ⌅
snippet command     # ⌘
snippet option      # ⌥
snippet delete      # ⌦
snippet backspace       # ⌫
snippet escape      # ⎋
snippet doctype HTML 4.01 Strict        # Generic Doctype
snippet doctype HTML 4.01 Transitional      
snippet doctype HTML 5      
snippet doctype XHTML 1.0 Frameset      
snippet doctype XHTML 1.0 Strict        
snippet doctype XHTML 1.0 Transitional      
snippet doctype XHTML 1.1       
snippet docts       # HTML Doctype 4.01 Strict
snippet doct        # HTML Doctype 4.01 Transitional
snippet doct5       # HTML Doctype 5
snippet docxf       # XHTML Doctype 1.0 Frameset
snippet docxs       # XHTML Doctype 1.0 Strict
snippet docxt       # XHTML Doctype 1.0 Transitional
snippet docx        # XHTML Doctype 1.1
snippet html        
snippet xhtml       
snippet body        
snippet head        
snippet title       
snippet script      
snippet scriptsrc       
snippet style       
snippet base        
snippet r       
snippet div     
snippet movie       # Embed QT Movie
snippet fieldset        
snippet form        
snippet h1      
snippet input       
snippet label       
snippet link        
snippet mailto      
snippet meta        
snippet opt     
snippet optt        
snippet select      
snippet table       
snippet textarea        
snippet fcg     
于 2012-11-26T11:37:18.087 回答
2

不。

坦率地说,我不认为该选项完全有用。片段的目的是它们是在输入短单词时插入的文本,因此您不必完整输入它们。它们是您熟记于心的东西,只是不想一遍又一遍地输入。

它们不是半可视化编程方式的代码块,您只需插入预定义的块。这似乎是你的目标。

检查代码片段的最简单方法是浏览代码片段文件。

于 2011-12-23T00:16:17.083 回答
1

<Plug>snipMateShow Default: <C-R><Tab> Mode: Insert Show all available snippets (that start with the previous text, if it exists). Use in insert mode.

于 2018-12-26T16:51:05.147 回答