查看Snipmate(cheatsheet)的可用片段

时间:2011-12-22 17:29:20

标签: vim snipmate

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

我很好奇:

  • 它将完成的字符串。
  • 如果可以使用代码段进行说明或评论。

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

3 个答案:

答案 0 :(得分:6)

这可能有所帮助,也可能无效,但我整理了一个'ls_snip'shell脚本,该脚本将列出各种文件类型和任何前面注释的片段。它不以任何方式集成到vim中,并且依赖于在* nix OS上。此外,仅适用于snippets / filetype.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     

答案 1 :(得分:2)

坦率地说,我并不认为这个选项完全是非常有用的。出于片段的目的,它们是在输入短词时插入的文本,因此您不必完全键入它们。他们是你心中所知的东西,只是不想一遍又一遍地打字。

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

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

答案 2 :(得分: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.