Skip to content

Instantly share code, notes, and snippets.

@xsephiroth
Created March 27, 2020 09:28
Show Gist options
  • Save xsephiroth/0c97763da02b1b31e81098b2b36564ea to your computer and use it in GitHub Desktop.
Save xsephiroth/0c97763da02b1b31e81098b2b36564ea to your computer and use it in GitHub Desktop.
.vimrc
" jsx [insert]<Tab>: auto complete html tag
" div
" <div></div>
autocmd BufNewFile,BufRead *.js,*.jsx inoremap <Tab> <Esc>^i<<Esc>$a><Esc>^v$y$pbi/<Esc>h
" jsx [normal]/!: to self close tag
" <div>abc</div>
" <div />abc
autocmd BufNewFile,BufRead *.js,*.jsx nnoremap /! ^f>i /<Esc>f<vf>xF
" jsx [insert]rfc<Tab>: react function component snippet
" import React from 'react';
"
" const _ = () => {
" };
"
" export default _;
"
autocmd BufNewFile,BufRead *.js,*.jsx inoremap rfc<Tab> <Esc>ggdGiimport React from 'react';<CR><CR>const _ = () => {<CR>};<CR><CR>export default _;<CR><Esc>gg/_<CR>
" go [insert]err<Tab>
" if err != nil {
" }
autocmd BufNewFile,BufRead *.go inoremap err<Tab> <Esc>^iif err != nil {<CR>}<Esc>k
" go [insert]pkgm<Tab> init main package codes
" package main
"
" func main() {
" }
autocmd BufNewFile,BufRead *.go inoremap pkgm<Tab> package main<CR><CR>func main() {<CR>}<Esc>k
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment