Skip to content

Commit

Permalink
add snippets and update replace cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
beiyuu committed Dec 21, 2014
1 parent b2f3bac commit 1e7b911
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 17 deletions.
61 changes: 45 additions & 16 deletions UltiSnips/all.snippets
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,26 @@

snippet $ajax
$.ajax({
type: 'POST'
,url: '${1}'
,data: {
ck: ck
${2}
}
,success: function(data) {
if(data.r){
${3}
}else{
${4}
}
}
});
type: 'POST',
url: '${1}',
data: {
${2}
}
}).done(function(data) {
if(data.r){
${3}
}else{
${4}
}
}).fail(function() {
${5}
})
endsnippet

snippet $on
$('${1}').on('${2:event}', '${3:element}', function(e){
e.preventDefault();
${4}
});
})
endsnippet

snippet bjs
Expand All @@ -42,3 +41,33 @@ endsnippet
snippet log
console.log(${1})
endsnippet

snippet req "require" b
var `!p
def formatVariableName(path):
lastPart = path.split('/')[-1]
if lastPart == 'underscore':
return '_'
elif lastPart == 'jquery':
return '$'
else:
return re.sub(r'[_\-]', '', lastPart.title())
snip.rv = formatVariableName(t[1])
` = require('${1}')$0
endsnippet

snippet me "module.exports" b
module.exports = ${1:`!p snip.rv = ''.join(x.title() for x in re.sub('\.js$', '', snip.basename or 'ModuleName').split('_'))`}$0
endsnippet

snippet cc "createClass" b
var ${1:`!p snip.rv = ''.join(x.title() for x in re.sub('\.js$', '', snip.basename or 'ModuleName').split('_'))`} = React.createClass({
render: function() {
return (
$0
)
}
})

module.exports = $1
endsnippet
2 changes: 1 addition & 1 deletion _vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ nmap <leader>ch ^xx
"切换到当前目录
nmap <leader>q :execute "cd" expand("%:h")<CR>
"搜索替换
nmap <leader>s :,s///c
nmap <leader>s :1,%s///cg<left><left><left><left>
"取消粘贴缩进
nmap <leader>p :set paste<CR>
Expand Down

0 comments on commit 1e7b911

Please sign in to comment.