{"id":13479839,"url":"https://github.com/prettier/vim-prettier","last_synced_at":"2025-05-15T08:10:21.890Z","repository":{"id":37580248,"uuid":"92342567","full_name":"prettier/vim-prettier","owner":"prettier","description":"A Vim plugin for Prettier","archived":false,"fork":false,"pushed_at":"2024-06-11T15:49:17.000Z","size":899,"stargazers_count":1821,"open_issues_count":63,"forks_count":141,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-05-11T15:29:35.386Z","etag":null,"topics":["prettier","prettier-js","vim","vim-plugins"],"latest_commit_sha":null,"homepage":"","language":"Vim Script","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/prettier.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"prettier","open_collective":"prettier","tidelift":"npm/prettier"}},"created_at":"2017-05-24T22:39:57.000Z","updated_at":"2025-04-30T17:27:25.000Z","dependencies_parsed_at":"2024-11-05T23:39:52.702Z","dependency_job_id":"1330ca97-f305-454e-96c5-ed4e9e724521","html_url":"https://github.com/prettier/vim-prettier","commit_stats":{"total_commits":386,"total_committers":66,"mean_commits":5.848484848484849,"dds":"0.34196891191709844","last_synced_commit":"7dbdbb12c50a9f4ba72390cce2846248e4368fd0"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prettier%2Fvim-prettier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prettier%2Fvim-prettier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prettier%2Fvim-prettier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prettier%2Fvim-prettier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prettier","download_url":"https://codeload.github.com/prettier/vim-prettier/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254301433,"owners_count":22047904,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["prettier","prettier-js","vim","vim-plugins"],"created_at":"2024-07-31T16:02:23.758Z","updated_at":"2025-05-15T08:10:21.853Z","avatar_url":"https://github.com/prettier.png","language":"Vim Script","readme":"## vim-prettier \n\nA vim plugin wrapper for prettier, pre-configured with custom default prettier\nsettings.\n\n---\n\n**NOTE**: If you want to fallback to older version of prettier/vim-prettier please add this to your `.vimrc`:\n\n```vim\nPlug 'prettier/vim-prettier', {\n  \\ 'do': 'yarn install --frozen-lockfile --production',\n  \\ 'branch': 'release/0.x'\n  \\ }\n```\n\n---\n\nBy default it will auto format **javascript**, **typescript**, **less**,\n**scss**, **css**, **json**, **graphql** and **markdown** files if they\nhave/support the \"@format\" pragma annotation in the header of the file.\n\n![vim-prettier](/media/vim-prettier.gif?raw=true 'vim-prettier')\n\n### INSTALL\n\nTo install with vim 8+ plugins, simply clone to your `~/.vim/pack/plugins/start` directory, and add `packloadall` to your `.vimrc` (if you haven't already).\n\n```bash\nmkdir -p ~/.vim/pack/plugins/start\ngit clone https://github.com/prettier/vim-prettier ~/.vim/pack/plugins/start/vim-prettier\n```\n\n`.vimrc`:\n```vim\npackloadall\n```\n\nInstall with [vim-plug](https://github.com/junegunn/vim-plug), assumes node and\nyarn|npm installed globally.\n\n```vim\n\" post install (yarn install | npm install) then load plugin only for editing supported files\nPlug 'prettier/vim-prettier', {\n  \\ 'do': 'yarn install --frozen-lockfile --production',\n  \\ 'for': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'graphql', 'markdown', 'vue', 'svelte', 'yaml', 'html'] }\n```\n\nor simply enable for all formats by:\n\n```vim\n\" post install (yarn install | npm install) then load plugin only for editing supported files\nPlug 'prettier/vim-prettier', { 'do': 'yarn install --frozen-lockfile --production' }\n```\n\nFor those using [vim-pathogen](https://github.com/tpope/vim-pathogen), you can run the following in a terminal:\n\n```\ncd ~/.vim/bundle\ngit clone https://github.com/prettier/vim-prettier\n```\n\nIf using [dein](https://github.com/Shougo/dein.vim), add the following to your dein config:\n\n```vim\ncall dein#add('prettier/vim-prettier', {'build': 'npm install'})\n```\n\nIf using other vim plugin managers or doing manual setup make sure to have\n`prettier` installed globally or go to your vim-prettier directory and either do\n`npm install` or `yarn install --frozen-lockfile`\n\n### Prettier Executable resolution\n\nWhen installed via vim-plug, a default prettier executable is installed inside\nvim-prettier.\n\nvim-prettier executable resolution:\n\n1.  Look for user defined prettier cli path from vim configuration file\n2.  Traverse parents and search for Prettier installation inside `node_modules`\n3.  Look for a global prettier installation\n4.  Use locally installed vim-prettier prettier executable\n\n### Prettier Stylelint\n\nTo use an alternative command, like\n[`prettier-stylelint`](https://github.com/hugomrdias/prettier-stylelint), set\nthis at the buffer level, e.g.:\n\n```vim\nau FileType css,scss let b:prettier_exec_cmd = \"prettier-stylelint\"\n```\n\nvim-prettier will look for the executable in the same places it looks for\n`prettier`, and will fall back to `prettier` if it can't find\n`b:prettier_exec_cmd`\n\n### USAGE\n\nPrettier by default will run on auto save but can also be manually triggered by:\n\n```vim\n\u003cLeader\u003ep\n```\n\nor\n\n```vim\n:Prettier\n```\n\nIf your are on vim 8+ you can also trigger async formatting by:\n\n```vim\n:PrettierAsync\n```\n\nYou can send to prettier your entire buffer but ensure that it formats only your selection.\n\n**note:** differs from `:PrettierFragment` by sending the entire buffer to prettier, allowing identation level to be preserved, but it requires the whole file to be valid.\n\n```vim\n:PrettierPartial\n```\n\nYou can send to prettier your current selection as a fragment of same type as the file being edited.\n\n**note:** differs from `:PrettierPartial` by sending only the current selection to prettier, this allows for faster formatting but wont preserve indentation.\n\n```vim\n:PrettierFragment\n```\n\nYou can check what is the `vim-prettier` plugin version by:\n\n```vim\n:PrettierVersion\n```\n\nYou can send commands to the resolved `prettier` cli by:\n\n```\n:PrettierCli \u003cq-args\u003e\n```\n\nYou can check what is the resolved `prettier` cli path by:\n\n```vim\n:PrettierCliPath\n```\n\nYou can check what is the resolved `prettier` cli version by:\n\n```vim\n:PrettierCliVersion\n```\n\n### Configuration\n\nChange the mapping to run from the default of `\u003cLeader\u003ep`\n\n```vim\nnmap \u003cLeader\u003epy \u003cPlug\u003e(Prettier)\n```\n\nEnable auto formatting of files that have \"@format\" or \"@prettier\" tag\n\n```vim\nlet g:prettier#autoformat = 1\n```\n\nAllow auto formatting for files without \"@format\" or \"@prettier\" tag\n\n```vim\nlet g:prettier#autoformat_require_pragma = 0\n```\n\n**NOTE** The previous two options can be used together for autoformatting files on save without `@format` or `@prettier` tags\n\n```vim\nlet g:prettier#autoformat = 1\nlet g:prettier#autoformat_require_pragma = 0\n```\n\nToggle the `g:prettier#autoformat` setting based on whether a config file can be found in the current directory or any parent directory. Note that this will override the `g:prettier#autoformat` setting!\n\n```vim\nlet g:prettier#autoformat_config_present = 1\n```\n\nA list containing all config file names to search for when using the `g:prettier#autoformat_config_present` option.\n\n```vim\nlet g:prettier#autoformat_config_files = [...]\n```\n\nSet the prettier CLI executable path\n\n```vim\nlet g:prettier#exec_cmd_path = \"~/path/to/cli/prettier\"\n```\n\nThe command `:Prettier` by default is synchronous but can also be forced async\n\n```vim\nlet g:prettier#exec_cmd_async = 1\n```\n\nBy default parsing errors will open the quickfix but can also be disabled\n\n```vim\nlet g:prettier#quickfix_enabled = 0\n```\n\nBy default selection formatting will be running `:PrettierFragment` but we can set\n`:PrettierPartial` as the default selection formatting by:\n\n```vim\nlet g:prettier#partial_format=1\n```\n\nBy default we auto focus on the quickfix when there are errors but can also be disabled\n\n```vim\nlet g:prettier#quickfix_auto_focus = 0\n```\n\nTo run vim-prettier not only before saving, but also after changing text or leaving insert mode:\n\n```vim\n\" when running at every change you may want to disable quickfix\nlet g:prettier#quickfix_enabled = 0\n\nautocmd TextChanged,InsertLeave *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue,*.svelte,*.yaml,*.html PrettierAsync\n```\n\n### Overwrite default prettier configuration\n\n**Note:** vim-prettier default settings differ from prettier intentionally.\nHowever they can be configured by:\n\n```vim\n\" Max line length that prettier will wrap on: a number or 'auto' (use\n\" textwidth).\n\" default: 'auto'\nlet g:prettier#config#print_width = 'auto'\n\n\" number of spaces per indentation level: a number or 'auto' (use\n\" softtabstop)\n\" default: 'auto'\nlet g:prettier#config#tab_width = 'auto'\n\n\" use tabs instead of spaces: true, false, or auto (use the expandtab setting).\n\" default: 'auto'\nlet g:prettier#config#use_tabs = 'auto'\n\n\" flow|babylon|typescript|css|less|scss|json|graphql|markdown or empty string\n\" (let prettier choose).\n\" default: ''\nlet g:prettier#config#parser = ''\n\n\" cli-override|file-override|prefer-file\n\" default: 'file-override'\nlet g:prettier#config#config_precedence = 'file-override'\n\n\" always|never|preserve\n\" default: 'preserve'\nlet g:prettier#config#prose_wrap = 'preserve'\n\n\" css|strict|ignore\n\" default: 'css'\nlet g:prettier#config#html_whitespace_sensitivity = 'css'\n\n\" false|true\n\" default: 'false'\nlet g:prettier#config#require_pragma = 'false'\n\n\" Define the flavor of line endings\n\" lf|crlf|cr|all\n\" defaut: 'lf'\nlet g:prettier#config#end_of_line = get(g:, 'prettier#config#end_of_line', 'lf')\n```\n\n### REQUIREMENT(S)\n\nIf the `prettier` executable can't be found by Vim, no code formatting will happen\n","funding_links":["https://github.com/sponsors/prettier","https://opencollective.com/prettier","https://tidelift.com/funding/github/npm/prettier"],"categories":["Vim Script","Shell","🔌 Editor Integrations"],"sub_categories":["Editors"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprettier%2Fvim-prettier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprettier%2Fvim-prettier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprettier%2Fvim-prettier/lists"}