Key Mappings (<Plug>)
Complete reference for all 38+ <Plug> key mappings in coc.nvim for navigation, refactoring, diagnostics, and text objects.
Vim Key Mappings (<Plug>)
coc.nvim exposes a rich set of <Plug> key-mappings for normal, visual, insert, and operator-pending modes. These mappings provide ergonomic wrappers around core LSP features, diagnostics, refactorings, float navigation, and text objects.
Overview & Guidelines
When mapping <Plug> targets in your init.vim or .vimrc, keep the following rules in mind:
- Always use
map/nmap/xmap/omap(NOTnoremap):
Usingnoremapwith<Plug>will prevent Vim from expanding the key mapping and it will not work at all. - Use
<silent>to suppress echo noise:
nmap <silent> gd <Plug>(coc-definition) - Lua (
init.lua) syntax:
vim.keymap.set("n", "gd", "<Plug>(coc-definition)", { silent = true }) - Local Key-mappings enabled automatically in active modes:
- Snippet active jumps:
g:coc_snippet_prevandg:coc_snippet_next. - Cursor sessions: Multiple cursor navigation and escape bindings.
- Float / Dialog windows: Confirm (
<CR>), cancel (<Esc>), and scroll keys. - CocList picker buffers: Navigation and action triggers.
- Snippet active jumps:
Diagnostic Navigation
<Plug>(coc-diagnostic-info)
Show the diagnostic message of the current position in a floating window / popup by invoking CocAction('diagnosticInfo').
| 1 | nmap <silent> <space>e <Plug>(coc-diagnostic-info) |
<Plug>(coc-diagnostic-next)
Jump to the next diagnostic position after the current cursor position.
| 1 | nmap <silent> ]g <Plug>(coc-diagnostic-next) |
<Plug>(coc-diagnostic-prev)
Jump to the previous diagnostic position before the current cursor position.
| 1 | nmap <silent> [g <Plug>(coc-diagnostic-prev) |
<Plug>(coc-diagnostic-next-error)
Jump specifically to the next diagnostic position that has an Error severity level, skipping warnings and hints.
| 1 | nmap <silent> ]e <Plug>(coc-diagnostic-next-error) |
<Plug>(coc-diagnostic-prev-error)
Jump specifically to the previous diagnostic position that has an Error severity level.
| 1 | nmap <silent> [e <Plug>(coc-diagnostic-prev-error) |
Code Navigation & Definition
<Plug>(coc-definition)
Jump to definition(s) of the symbol under cursor by invoking CocAction('jumpDefinition'). If multiple definitions exist, a location list or picker opens.
| 1 | nmap <silent> gd <Plug>(coc-definition) |
<Plug>(coc-declaration)
Jump to declaration(s) of current symbol by invoking CocAction('jumpDeclaration').
| 1 | nmap <silent> gD <Plug>(coc-declaration) |
<Plug>(coc-implementation)
Jump to implementation(s) of current interface/class symbol by invoking CocAction('jumpImplementation').
| 1 | nmap <silent> gi <Plug>(coc-implementation) |
<Plug>(coc-type-definition)
Jump to type definition(s) of current symbol by invoking CocAction('jumpTypeDefinition').
| 1 | nmap <silent> gy <Plug>(coc-type-definition) |
<Plug>(coc-references)
Find and jump to all references of current symbol by invoking CocAction('jumpReferences').
| 1 | nmap <silent> gr <Plug>(coc-references) |
<Plug>(coc-references-used)
Jump to references of current symbol excluding definition positions by invoking CocAction('jumpUsed').
| 1 | nmap <silent> gR <Plug>(coc-references-used) |
Refactoring & Formatting
<Plug>(coc-rename)
Rename symbol under the cursor across the entire workspace by invoking CocAction('rename'). Prompts with a float input box or cmdline.
| 1 | nmap <leader>rn <Plug>(coc-rename) |
<Plug>(coc-format)
Format the entire current document using registered LSP formatters by invoking CocAction('format').
| 1 | nmap <leader>f <Plug>(coc-format) |
<Plug>(coc-format-selected)
Format selected range in visual mode or operator-pending mode by invoking CocAction('formatSelected').
| 1 | xmap <leader>f <Plug>(coc-format-selected) |
| 2 | nmap <leader>f <Plug>(coc-format-selected) |
<Plug>(coc-refactor)
Open refactor window with occurrences of the symbol under cursor by invoking CocAction('refactor'). Allows direct batch editing and saving changes across all files.
| 1 | nmap <silent> <leader>rf <Plug>(coc-refactor) |
Code Actions & Quickfix
<Plug>(coc-codeaction)
Get and execute Code Actions for current selected range or cursor position by invoking CocAction('codeAction').
| 1 | xmap <leader>a <Plug>(coc-codeaction-selected) |
| 2 | nmap <leader>a <Plug>(coc-codeaction-selected) |
<Plug>(coc-codeaction-source)
Execute code actions with source kind (such as organize imports) for current buffer.
<Plug>(coc-codeaction-line)
Execute code action specifically targeting the current line.
| 1 | nmap <leader>al <Plug>(coc-codeaction-line) |
<Plug>(coc-codeaction-cursor)
Execute code action specifically targeting the exact cursor position.
| 1 | nmap <leader>ac <Plug>(coc-codeaction-cursor) |
<Plug>(coc-codeaction-selected)
Execute code action for the visual selection or operator target.
<Plug>(coc-codeaction-refactor)
Execute code action with refactor kind for current buffer.
<Plug>(coc-codeaction-refactor-selected)
Execute refactor code actions for the selected range.
<Plug>(coc-fix-current)
Apply the first preferred quickfix codeaction for the diagnostic on the current line by invoking CocAction('doQuickfix').
| 1 | nmap <leader>qf <Plug>(coc-fix-current) |
<Plug>(coc-codelens-action)
Trigger the CodeLens action on the current line.
| 1 | nmap <leader>cl <Plug>(coc-codelens-action) |
Floating Windows & Links
<Plug>(coc-float-jump)
Jump into the active floating hover or diagnostic window. Once inside, you can navigate, copy text, or press q / <Esc> to close.
| 1 | nmap <silent> <space>j <Plug>(coc-float-jump) |
<Plug>(coc-float-hide)
Hide all currently open floating hover, signature help, and diagnostic windows.
| 1 | nmap <silent> <space>h <Plug>(coc-float-hide) |
<Plug>(coc-openlink)
Open link under cursor using your system's default browser or handler by invoking CocAction('openLink').
| 1 | nmap <silent> gx <Plug>(coc-openlink) |
Selection & Text Objects
<Plug>(coc-range-select)
Expand the current visual selection semantically based on AST ranges (Selection Range feature of LSP). Repeated hits expand to parent AST nodes.
| 1 | nmap <silent> <C-s> <Plug>(coc-range-select) |
| 2 | xmap <silent> <C-s> <Plug>(coc-range-select) |
<Plug>(coc-range-select-backward)
Shrink the semantic selection range back to inner child AST nodes.
| 1 | xmap <silent> <C-r> <Plug>(coc-range-select-backward) |
<Plug>(coc-funcobj-i) & <Plug>(coc-funcobj-a)
Inner and around function text objects provided by LSP document symbols.
| 1 | xmap if <Plug>(coc-funcobj-i) |
| 2 | omap if <Plug>(coc-funcobj-i) |
| 3 | xmap af <Plug>(coc-funcobj-a) |
| 4 | omap af <Plug>(coc-funcobj-a) |
<Plug>(coc-classobj-i) & <Plug>(coc-classobj-a)
Inner and around class / struct / interface text objects provided by LSP document symbols.
| 1 | xmap ic <Plug>(coc-classobj-i) |
| 2 | omap ic <Plug>(coc-classobj-i) |
| 3 | xmap ac <Plug>(coc-classobj-a) |
| 4 | omap ac <Plug>(coc-classobj-a) |
Multiple Cursors
<Plug>(coc-cursors-operator)
Operator mapping to start a multiple cursors session on text object or motion.
| 1 | nmap <silent> <leader>c <Plug>(coc-cursors-operator) |
<Plug>(coc-cursors-word)
Add occurrences of the word under cursor to the multiple cursors session in normal mode.
| 1 | nmap <silent> <C-n> <Plug>(coc-cursors-word) |
<Plug>(coc-cursors-position)
Add the current cursor position to active multiple cursors session.
| 1 | nmap <silent> <C-d> <Plug>(coc-cursors-position) |
<Plug>(coc-cursors-range)
Add visual range selection to the multiple cursors session.
| 1 | xmap <silent> <C-n> <Plug>(coc-cursors-range) |
Command Repeat
<Plug>(coc-command-repeat)
Repeat the last executed coc command or action.
| 1 | nmap <silent> <leader>. <Plug>(coc-command-repeat) |
Complete mapping index
<Plug>(coc-classobj-a)— Select around class/struct/interface. Works on both visual-mode and normal-mode. Recommended mapping: Note: Requires 'textDocument.documentSymbol' support from the language server. Example:xmap ac <Plug>(coc-classobj-a) omap ac <Plug>(coc-classobj-a).
<Plug>(coc-classobj-i)— Select inside class/struct/interface. Works on both visual-mode and normal-mode. Recommended mapping: Note: Requires 'textDocument.documentSymbol' support from the language server. Example:xmap ic <Plug>(coc-classobj-i) omap ic <Plug>(coc-classobj-i).
<Plug>(coc-codeaction-cursor)— Get and run code action(s) using an empty range at the current cursor.
<Plug>(coc-codeaction-line)— Get and run code action(s) for the current line.
<Plug>(coc-codeaction-refactor-selected)— Get and run refactor code action(s) with selected code. Works on both visual-mode and normal-mode.
<Plug>(coc-codeaction-refactor)— Get and run refactor code action(s) at the current cursor, the same as the refactor context menu in VSCode; disabled actions aren't excluded.
<Plug>(coc-codeaction-selected)— Get and run code action(s) with the selected code. Works on both visual-mode and normal-mode.
<Plug>(coc-codeaction-source)— Get and run source code action(s) for current file. The same as 'Source action...' in VSCode's context menu.
<Plug>(coc-codeaction)— Get and run code action(s) for the current file; use <Plug>(coc-codeaction-cursor) for the same behavior as VSCode.
<Plug>(coc-codelens-action)— Invoke the command contributed by codeLens at the current line.
<Plug>(coc-command-repeat)— Repeat latest :CocCommand.
<Plug>(coc-cursors-operator)— Add text to the cursors session using a motion object.
<Plug>(coc-cursors-position)— Add the current position as an empty range to the cursors session.
<Plug>(coc-cursors-range)— Add selection to cursors session.
<Plug>(coc-cursors-word)— Add the current word to the cursors session.
<Plug>(coc-declaration)— Jump to declaration(s) of current symbol by invoke CocAction('jumpDeclaration')
<Plug>(coc-definition)— Jump to definition(s) of the current symbol by invoking CocAction('jumpDefinition')
<Plug>(coc-diagnostic-info)— Show the diagnostic message of the current position by invoking CocAction('diagnosticInfo').
<Plug>(coc-diagnostic-next-error)— Jump to next diagnostic error position.
<Plug>(coc-diagnostic-next)— Jump to next diagnostic position after current cursor position.
<Plug>(coc-diagnostic-prev-error)— Jump to previous diagnostic error position.
<Plug>(coc-diagnostic-prev)— Jump to previous diagnostic position before current cursor position.
<Plug>(coc-fix-current)— Try the first quickfix action for diagnostics of the current line.
<Plug>(coc-float-hide)— Hide all float windows/popups created by coc.nvim.
<Plug>(coc-float-jump)— Jump to the first float window (Neovim only); use CTRL-W_p to jump to the previous window.
<Plug>(coc-format-selected)— Formats the selected range and works in both visual-mode and normal-mode. When used in normal mode, the selection works on the motion object. makes <leader>p format the visually selected range, and you can use <leader>pap to format a paragraph. Example:vmap <leader>p <Plug>(coc-format-selected) nmap <leader>p <Plug>(coc-format-selected).
<Plug>(coc-format)— Format the whole buffer by invoking CocAction('format').
<Plug>(coc-funcobj-a)— Select around function. Works on both visual-mode and normal-mode. Recommended mapping: Note: Requires 'textDocument.documentSymbol' support from the language server. Example:xmap af <Plug>(coc-funcobj-a) omap af <Plug>(coc-funcobj-a).
<Plug>(coc-funcobj-i)— Select inside function. Recommended mapping: Works on both visual-mode and normal-mode. Note: Requires 'textDocument.documentSymbol' support from the language server. Example:xmap if <Plug>(coc-funcobj-i) omap if <Plug>(coc-funcobj-i).
<Plug>(coc-implementation)— Jump to implementation(s) of current symbol by invoke CocAction('jumpImplementation')
<Plug>(coc-openlink)— Open the link under the cursor by using CocAction('openLink').
<Plug>(coc-range-select-backward)— Select previous selection range.
<Plug>(coc-range-select)— Select next selection range. Works on both visual-mode and normal-mode.
<Plug>(coc-refactor)— Open the refactor window to refactor the current symbol by invoking CocAction('refactor').
<Plug>(coc-references-used)— Jump to references of the current symbol, excluding declarations.
<Plug>(coc-references)— Jump to references of current symbol by invoke CocAction('jumpReferences')
<Plug>(coc-rename)— Rename the symbol under the cursor to a new word by invoking CocAction('rename').
<Plug>(coc-type-definition)— Jump to type definition(s) of current symbol by invoke CocAction('jumpTypeDefinition')