Skip to content

Instantly share code, notes, and snippets.

@mbao01
Last active April 17, 2019 00:30
Show Gist options
  • Save mbao01/e0dcf53ec67b1044f7c3da390f4decf5 to your computer and use it in GitHub Desktop.
Save mbao01/e0dcf53ec67b1044f7c3da390f4decf5 to your computer and use it in GitHub Desktop.
My preferred VS Code setup

VSCODE SETTING

Extensions

User setting > setting.json

{
    "window.titleBarStyle": "custom",
    "workbench.iconTheme": "material-icon-theme",
    "workbench.colorTheme": "Material Theme Palenight",
    "workbench.colorCustomizations": {
        "[Material Theme Palenight]": {}
    },
    "editor.fontFamily": "'Fira Code Retina', 'Liberation Mono', 'Source Code Pro', 'Droid Sans Mono', 'monospace', monospace, 'Droid Sans Fallback'",
    "editor.fontSize": 16,
    "editor.formatOnSave": true,
    "explorer.autoReveal": false,
    "window.zoomLevel": 0,
    "breadcrumbs.enabled": true,
    "eslint.enable": true,
    "editor.fontLigatures": true,
    "editor.tokenColorCustomizations": {
        "textMateRules": [{
            "scope": [
                "keyword.control",
                "entity.other.attribute-name"
            ],
            "settings": {
                "fontStyle": ""
            }
        }]
    },
    "prettier.eslintIntegration": false,
    "prettier.bracketSpacing": false,
    "prettier.printWidth": 80,
    "prettier.tabWidth": 2,
    "prettier.singleQuote": true,
    "prettier.trailingComma": "all",
    "prettier.jsxBracketSameLine": false,
    "prettier.semi": false,
    "prettier.useTabs": false,
    "prettier.proseWrap": "always",
    "prettier.requireConfig": true,
}

Key bindings > keybindings.json

// Place your key bindings in this file to override the defaultsauto[]
[
    {
        "key": "ctrl+shift+`",
        "command": "workbench.action.reopenClosedEditor"
    },
    {
        "key": "ctrl+shift+t",
        "command": "-workbench.action.reopenClosedEditor"
    },
    {
        "key": "ctrl+`",
        "command": "workbench.action.terminal.new"
    },
    {
        "key": "ctrl+shift+`",
        "command": "-workbench.action.terminal.new"
    },
    {
        "key": "alt+h",
        "command": "workbench.action.maximizeEditor"
    },
    {
        "key": "ctrl+shift+t",
        "command": "workbench.action.terminal.toggleTerminal"
    },
    {
        "key": "ctrl+`",
        "command": "-workbench.action.terminal.toggleTerminal"
    }
]

User snippets > javascript.json

{
	"console.log": {
		"prefix": "cl",
		"body": "console.log(${1:'here'})$0"
	},
	"console.log('var', var)": {
		"prefix": "vl",
		"body": "console.log('$1', $1)$0"
	},
	"console.log({var})": {
		"prefix": "ol",
		"body": "console.log({$1})$0"
	},
	"import x from '": {
		"prefix": "imp",
		"body": "import ${2:*} from '$1'$3"
	},
	"eslint rule": {
		"prefix": "esl",
		"body": "/* eslint $1:0 */"
	},
	"eslint disable next line": {
		"prefix": "eslnl",
		"body": "// eslint-disable-next-line $1"
	},
	"eslint disable line": {
		"prefix": "esll",
		"body": "// eslint-disable-line $1"
	},
	"constructor": {
		"prefix": "ctor",
		"body": [
			"constructor(...args) {",
			"  super(...args)",
			"  $0",
			"}"
		]
	},
	"try/catch": {
		"prefix": "try",
		"body": [
			"try {",
			"  $1",
			"} catch (error) {",
			"  $0",
			"}"
		]
	},
	"async function": {
		"prefix": "afun",
		"body": [
			"async function $1($2) {",
			"  $0",
			"}"
		]
	},
	"throw log": {
		"prefix": "tl",
		"body": "throw new Error(JSON.stringify({$0}, null, 2))"
	},
	"spaced console.log": {
		"prefix": "scl",
		"body": [
			"console.log('**************************************************************************\\\\n\\\\n\\\\n')",
			"console.log($0)",
			"console.log('\\\\n\\\\n\\\\n**************************************************************************')"
		]
	},
	"React Component": {
		"prefix": "rc",
		"body": [
			"class $1 extends React.Component {",
			"  render() {",
			"    $0",
			"  }",
			"}"
		]
	},
	"React: componentWillMount": {
		"prefix": "cwm",
		"body": [
			"componentWillMount() {",
			"  $0",
			"}"
		]
	},
	"React: componentDidMount": {
		"prefix": "cdm",
		"body": [
			"componentDidMount() {",
			"  $0",
			"}"
		]
	},
	"React: componentWillReceiveProps": {
		"prefix": "cwrp",
		"body": [
			"componentWillReceiveProps(nextProps) {",
			"  $0",
			"}"
		]
	},
	"React: componentWillUpdate": {
		"prefix": "cwu",
		"body": [
			"componentWillUpdate(nextProps, nextState) {",
			"  $0",
			"}"
		]
	},
	"React: componentDidUpdate": {
		"prefix": "cdu",
		"body": [
			"componentDidUpdate(prevProps, prevState) {",
			"  $0",
			"}"
		]
	},
	"React: componentWillUnmount": {
		"prefix": "cwu",
		"body": [
			"componentWillUnmount() {",
			"  $0",
			"}"
		]
	},
	"Jest test": {
		"prefix": "test",
		"body": [
			"test('$1', () => {",
			"  $0",
			"})"
		]
	},
	"Jest async test": {
		"prefix": "atest",
		"body": [
			"test('$1', async () => {",
			"  $0",
			"})"
		]
	},
	"Mocha it block": {
		"prefix": "it",
		"body": [
			"it('should $1', () => {",
			"  $2",
			"})"
		]
	},
	"Mocha describe block": {
		"prefix": "desc",
		"body": [
			"describe('$1', () => {",
			"  $2",
			"})"
		]
	},
	"split-guide final": {
		"prefix": "sgf",
		"body": [
			"// FINAL_START",
			"$1",
			"// FINAL_END"
		]
	},
	"split-guide workshop": {
		"prefix": "sgw",
		"body": [
			"// WORKSHOP_START",
			"$1",
			"// WORKSHOP_END"
		]
	},
	"split-guide comment": {
		"prefix": "sgc",
		"body": [
			"// COMMENT_START",
			"$1",
			"// COMMENT_END"
		]
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment