Skip to content

Commit

Permalink
update c.snip, cpp.snip, python.snip, and sh.snip
Browse files Browse the repository at this point in the history
cpp.snip: fix snippet of enum struct
* add name placeholder
* semicolon is required

cpp.snip: update snippet of try-catch
set default value `...` (any exception is catched)

cpp.snip: update snippet of lambda expression
* to jump to end of body
* semicolon is sometimes required (e.g. in case of declaration)

c.snip: update snippet of for
* add type specifier: default is int (C99 feature)
* set default index to i
* set default initial value to 0

python.snip: use hard tab for indentation

python.snip: set default value `pass`

sh.snip: fix snippet of heredoc
  • Loading branch information
e-kwsm committed Jul 15, 2015
1 parent 0fc709d commit b0010e8
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 36 deletions.
4 changes: 2 additions & 2 deletions neosnippets/c.snip
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ abbr if () {} else {}

snippet for
abbr for () {}
for (${1} = 0; $1 < ${2}; $1++) {
${0:TARGET}
for (${1:int} ${2:i} = ${3:0}; $2 < ${4}; $2++) {
${0:#:TARGET}
}

snippet while
Expand Down
10 changes: 5 additions & 5 deletions neosnippets/cpp.snip
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ abbr class {}
snippet try
abbr try catch
try {
${1:TARGET}
} catch (${2:e:xception}) {
${1:#:TARGET}
} catch (${2:...}) {
${3}
}

Expand All @@ -48,12 +48,12 @@ abbr for (:) {}
# lambda expression ( C++11 feature )
snippet lambda
abbr [](){}
[${1}](${2})${3}{ ${4:TARGET} }
[${1}](${2})${3}{ ${4:TARGET} }${0:;}

# scoped enumeration ( C++11 feature )
snippet enum_scoped
abbr enum struct {}
enum struct { ${1:TARGET} }
abbr enum struct {};
enum struct ${1:#:name} { ${2:#:TARGET} };

# static assert ( C++11 feature )
snippet static_assert
Expand Down
50 changes: 25 additions & 25 deletions neosnippets/python.snip
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ abbr class Class(...): ...
options head
class ${1:#:name}(${2:object}):
def __init__(self, ${3}):
${0}
${0:pass}

snippet classd
abbr class Class(...): "..."
Expand All @@ -19,129 +19,129 @@ options head
"""${3:#:class documentation}"""
def __init__(self, ${4}):
"""${5:#:__init__ documentation}"""
${0}
${0:pass}

snippet def
abbr def function(...): ...
options head
def ${1:#:name}(${2}):
${0:TARGET}
${0:pass}

snippet defd
abbr def function(...): """..."""
options head
def ${1:#:name}(${2}):
"""${3:#:function documentation}"""
${0:TARGET}
${0:pass}

snippet defm
abbr def method(self, ...): ...
options head
def ${1:#:name}(self, ${2}):
${0:TARGET}
${0:pass}

snippet defmd
abbr def method(self, ...): "..."
options head
def ${1:#:name}(self, ${2}):
"""${3:#:method documentation}"""
${0:TARGET}
${0:pass}

snippet elif
abbr elif ...: ...
options head
elif ${1:#:condition}:
${0}
${0:pass}

snippet else
abbr else: ...
options head
else:
${0}
${0:pass}

snippet fileidiom
abbr with open()
options head
with open(${1:#:filename}, '${2:#:mode}') as ${3:f}:
${0:TARGET}
${0:pass}

snippet for
abbr for ... in ...: ...
options head
for ${1:#:value} in ${2:#:list}:
${0:TARGET}
${0:pass}

snippet if
abbr if ...: ...
options head
if ${1:#:condition}:
${0:TARGET}
${0:pass}

snippet ifmain
abbr if __name__ == '__main__': ...
alias main
options head
if __name__ == '__main__':
${0:TARGET}
${0:pass}

snippet tryexcept
abbr try: ... except ...: ...
options head
try:
${1:TARGET}
${1:pass}
except ${2:#:ExceptionClass}:
${3}
${3:pass}

snippet tryfinally
abbr try: ... finally: ...
options head
try:
${1:TARGET}
${1:pass}
finally:
${2}
${2:pass}

snippet while
abbr while ...: ...
options head
while ${1:#:condition}:
${0:TARGET}
${0:pass}

snippet with
abbr with {func}({file}) as :
options head
with ${1:open}(${2:#:filename, mode}) as ${3:f}:
${0:TARGET}
${0:pass}

snippet filter
abbr [x for x in {list} if {condition}]
[$1 for ${1:x} in ${2:#:list} if ${3:#:condition}]

snippet print
options word
print(${0:TARGET})
print(${0:#:TARGET})

snippet coding
abbr # -*- coding ...
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-

snippet getattr
abbr getattr(..., ...)
options word
getattr(${1:#:obj}, ${2:#:attr})
getattr(${1:#:obj}, ${2:#:attr})

snippet setattr
abbr setattr(..., ...)
setattr(${1:#:obj}, ${2:#:attr}, ${3:#:value})
setattr(${1:#:obj}, ${2:#:attr}, ${3:#:value})

snippet hasattr
abbr hasattr(..., ...)
options word
hasattr(${1:#:obj}, ${2:#:attr})
hasattr(${1:#:obj}, ${2:#:attr})

snippet pdb
abbr import pdb..
import pdb; pdb.set_trace()
import pdb; pdb.set_trace()

snippet ipdb
abbr import ipdb..
import ipdb; ipdb.set_trace()
import ipdb; ipdb.set_trace()
9 changes: 5 additions & 4 deletions neosnippets/sh.snip
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ snippet until
done


snippet here
alias h
<<${1}
${0:TARGET}
snippet heredoc
alias h <<
<< ${1:EOF}
${0:#:TARGET}
$1

snippet env
#!/usr/bin/env ${1}
Expand Down

0 comments on commit b0010e8

Please sign in to comment.