A collection of Javascript (with ES2015 and Node.js) snippets for Vim heavily based on the work of awesome people like @zenorocha, @msanders and @honza and powered by vim-snipmate.
You need vim-snipmate installed. You can then install, using Plug (or any other vim plugin manager you want):
Plug 'grvcoelho/vim-javascript-snippets'
console.dir(${1:obj})
console.error(${1:obj})
console.info(${1:obj})
console.log(${1:obj})
console.warn(${1:obj})
debugger
${1:document}.addEventListener('${2:event}', ${3:function})
${1:document}.appendChild(${2:elem})
${1:document}.removeChild(${2:elem})
${1:document}.createElement(${2:elem})
${1:document}.createDocumentFragment(${2:elem})
${1:document}.classList.add('${2:class}')
${1:document}.classList.toggle('${2:class}')
${1:document}.classList.remove('${2:class}')
${1:document}.getElementById('${2:id}')
${1:document}.getElementsByClassName('${2:class}')
${1:document}.getElementsByTagName('${2:tag}')
${1:document}.getAttribute('${2:attr}')
${1:document}.setAttribute('${2:attr}', ${3:value})
${1:document}.removeAttribute('${2:attr}')
${1:document}.innerHTML = '${2:elem}'
${1:document}.textContent = '${2:content}'
${1:document}.querySelector('${2:selector}')
${1:document}.querySelectorAll('${2:selector}')
if (${1:condition}) {
${0}
}
if (${1:condition}) {
${2}
} else {
${3}
}
if (${1:condition}) {
${2}
} else if (${3:condition}) {
${0}
}
switch (${1:condition}) {
case ${2:when}:
${0}
}
try {
${1}
} catch (${2:err}) {
${0}
}
try {
${1}
} finally {
${0}
}
try {
${1}
} catch (${2:err}) {
${3}
} finally {
${0}
}
function ${1:name} (${2}) {
${3}
}
function (${1}) {
${2}
}
function* ${1:name} (${2}) {
${3}
}
function* (${1}) {
${2}
}
(${1}) => ${2}
(${1}) => {
${2}
}
const ${1} = ${0}
let ${1} = ${0}
JSON.parse(${1:obj})
JSON.stringify(${1:obj})
for (let i = 0 i < ${1:length} i++) {
${0}
}
for (${1:prop} in ${2:obj}) {
if ($2.hasOwnProperty($1)) {
${0}
}
}
for (let ${1:elem} of ${2:obj}) {
${0}
}
${1:array}.forEach((${2:item}) => {
${0}
})
while (${1:condition}) {
${0}
}
class ${1} {
${0}
}
class ${1} extends ${2} {
${0}
}
import ${1:module} from '{2:path}'
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -m 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
MIT © 2016