Skip to main content
Docs / VIM INTERFACE

Commands & Autocmds

Complete reference for all Ex user commands (:CocStart, :CocConfig, :CocList) and User autocommand events in coc.nvim.

Vim Commands & Autocommand Events

coc.nvim defines high-level Ex user commands for server lifecycle, configuration, extension management, and diagnostics, along with standard Vim User autocommand events for reactive UI hooks.

Vim User Commands (:Coc*)

:CocStart

Start the coc.nvim background service manually (only needed if g:coc_start_at_startup is set to 0).

:CocRestart

Restart the coc.nvim background service and reload all workspace language servers and extensions.

:CocConfig

Open global coc-settings.json in a new buffer for editing.

:CocLocalConfig

Open or create project-local .vim/coc-settings.json in a new buffer.

:CocInstall [{extensions}...]

Install one or more extensions from npm registry (e.g. :CocInstall coc-json coc-tsserver).

:CocUninstall {extension}

Uninstall an installed extension.

:CocUpdate

Check for and install updates for all installed coc extensions.

:CocUpdateSync

Synchronously update all extensions, blocking until complete (useful in automated installation scripts).

:CocList [{args}...]

Open coc.nvim's interactive fuzzy search picker list (e.g. :CocList files, :CocList diagnostics, :CocList outline, :CocList extensions, :CocList commands, :CocList symbols).

:CocCommand [{command}] [{args}...]

Execute an LSP or extension registered command with fuzzy completion support.

:CocOpenLog

Open coc.nvim's runtime log file in a new split buffer.

:CocInfo

Display comprehensive system and environment diagnostics (Node.js version, Vim version, OS, config paths, active language servers, loaded extensions).

:CocDiagnostics

Open Vim's location list with diagnostics for the current buffer.

:CocDisable & :CocEnable

Disable or re-enable coc.nvim globally in the current Vim session.

:CocOutline

Show the outline tree view for the current buffer.

:CocWatch {extension}

Start watch mode for local extension development, rebuilding on file changes.

:CocSearch {query}

Search text across workspace using ripgrep integration.


Autocommand Events (User Coc*)

coc.nvim emits standard User autocommands that allow you to hook into diagnostic updates, location changes, status updates, and window creation:

vim snippet
1autocmd User <EventName> <Command>

CocNvimInit

Triggered once when coc.nvim background service finishes initialization and all global extensions have booted.

vim snippet
1autocmd User CocNvimInit echo "coc.nvim is ready!"

CocDiagnosticChange

Triggered whenever diagnostics for the current buffer or workspace are updated by a language server.

vim snippet
1autocmd User CocDiagnosticChange call UpdateDiagnosticStatus()

CocStatusChange

Triggered whenever g:coc_status or language server progress message changes.

vim snippet
1autocmd User CocStatusChange redrawstatus

CocLocationsChange

Triggered when definition, declaration, implementation, or reference jump locations change.

CocJumpPlaceholder

Triggered when cursor jumps between snippet placeholders.

CocOpenFloat

Triggered when a floating preview or hover window opens.

CocTerminalOpen

Triggered when a coc-managed terminal buffer opens.


Practical Autocmd Examples

Auto-format on save with filetype exclusions:

vim snippet
1autocmd BufWritePre *.ts,*.tsx,*.js,*.py silent! call CocAction('format')

Auto-show hover documentation on CursorHold:

vim snippet
1autocmd CursorHold * silent! call CocActionAsync('highlight')

Redraw statusline immediately on LSP status changes:

vim snippet
1autocmd User CocStatusChange,CocDiagnosticChange redrawstatus
<!-- generated-current-vim-reference -->

Complete command index

  • :CocCommand — Run a command provided by coc.nvim or contributed by extensions; use <tab> for name completion. Opens coc-list-commands when {name} isn't provided.

  • :CocConfig — Edit the user config file coc-settings.json in coc#util#get_config_home().

  • :CocDiagnostics — Open Vim's location-list with diagnostics of the current buffer. The location list is automatically updated by default. When multiple location lists are opened for one buffer, only the first is automatically updated.

  • :CocDisable — Disable handling of Vim events; useful for debugging performance issues.

  • :CocFirst — Invoke default action for first item in the last {name} list.

  • :CocInfo — Show version and log information in a split window; useful for submitting a bug report.

  • :CocLast — Invoke default action for last item in the last {name} list.

  • :CocListCancel — Close the list; useful when the list isn't the current window.

  • :CocListResume — Reopen the last opened list; input and cursor position are preserved.

  • :CocLocalConfig — Edit or create .vim/coc-settings.json in current workspace folder.

  • :CocNext — Invoke the default action for the next item in the last {name} list.

  • :CocOutline — Invoke CocAction('showOutline') by notification.

  • :CocPrev — Invoke the default action for the previous item in the last {name} list.

  • :CocPrintErrors — Show errors from stderr of NodeJS process in a split window.

  • :CocStart — Start the coc.nvim server; does nothing if the server is already started.

  • :CocUninstall — Uninstall an extension; use <tab> to complete the extension name.

  • :CocUpdate — Update all coc extensions to the latest version.

  • :CocUpdateSync — Blocking version of :CocUpdate for coc extensions.

  • :CocWatch — Watch the loaded [extension] for reload on file change; use <tab> to complete the extension id.

Complete autocmd index

  • CocDiagnosticChange — Triggered after the diagnostic status has changed.

  • CocJumpPlaceholder — Triggered after the cursor jumps to a placeholder.

  • CocLocationsChange — For building a custom view of locations, set g:coc_enable_locationlist to 0 and use this autocmd with g:coc_jump_locations.

  • CocNvimInit — Triggered after the coc services have started.

  • CocOpenFloat — Triggered when a floating window is opened. The window isn't focused; use g:coc_last_float_win to get the window id.

  • CocOpenFloatPrompt — Triggered when a floating prompt window is opened (triggered after CocOpenFloat).

  • CocStatusChange — Triggered after g:coc_status changes; can be used to refresh the statusline.

  • CocTerminalOpen — Triggered when the terminal is shown; can be used for adjusting the window height.