{"id":13479871,"url":"https://github.com/skywind3000/vim-preview","last_synced_at":"2025-03-27T10:30:51.637Z","repository":{"id":38272737,"uuid":"130860365","full_name":"skywind3000/vim-preview","owner":"skywind3000","description":"The missing preview window for vim","archived":false,"fork":false,"pushed_at":"2020-03-08T06:05:59.000Z","size":637,"stargazers_count":168,"open_issues_count":11,"forks_count":24,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-10-30T13:38:37.608Z","etag":null,"topics":[],"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/skywind3000.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-24T13:40:56.000Z","updated_at":"2024-10-22T12:44:25.000Z","dependencies_parsed_at":"2022-08-18T15:23:51.586Z","dependency_job_id":null,"html_url":"https://github.com/skywind3000/vim-preview","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skywind3000%2Fvim-preview","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skywind3000%2Fvim-preview/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skywind3000%2Fvim-preview/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skywind3000%2Fvim-preview/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skywind3000","download_url":"https://codeload.github.com/skywind3000/vim-preview/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245826735,"owners_count":20678849,"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":[],"created_at":"2024-07-31T16:02:24.398Z","updated_at":"2025-03-27T10:30:51.322Z","avatar_url":"https://github.com/skywind3000.png","language":"Vim script","funding_links":[],"categories":["Vim Script"],"sub_categories":[],"readme":"# Preface\n\nThis plugin solves a series of user experience problems in vim's preview window and provide a handy way to preview tags, files and function signatures.\n\n**Note**: Active development on this plugin has stopped. The only future changes will be bug fixes.\n\nPlease see [vim-quickui](https://github.com/skywind3000/vim-quickui).\n\n# Installation\n\n```VimL\nPlug 'skywind3000/vim-preview'\n```\n\n# Commands\n\n`vim-preview` introduces several commands:\n\n\n| Command | Arguments | Description |\n|---------|-----------|-------------|\n| PreviewTag | `[tagname]` | Display the tag in the preview window circularly |\n| PreviewFile | `[+cmd]` `filename` | Display the file in the preview window |\n| PreviewClose | `N/A` | Close the preview window |\n| PreviewGoto | `command` | Open the previewing file in a non-preview window |\n| PreviewScroll | `offset` | Scroll preview window without leaving current window or inser mode |\n| PreviewQuickfix | `[linenr]` | Preview file in quickfix list |\n| PreviewSignature | `[function name]` | Preview the function signature circularly in the command line |\n\n\n## PreviewTag\n \nThis command can display tag definition in the preview window circularly:\n\n```VimL\nPreviewTag [tagname]\n```\n\nWhen the first argument `tagname` is not provided, current word under cursor is chosen as the tag name.\n\nEvery body uses a wide-screen display today, but the default preview window can still only be opened in a new split above or below current window. vsplit is usually better than split when you are working with a 16:9 LCD.\n\n`:PreviewTag` command will open the preview window on your favorite position (right by default), and the tag name will be highlighted.\n\n![](doc/preview-tag.png)\n\nPreviously, when we got multiple matches, `CTRL+]` or `CTRL+W }` will display a list:\n\n```text\n\t nr pri kind tag\t\tfile\n\t  1 F\tf    mch_delay\t\tos_amiga.c\n\t\t\tmch_delay(msec, ignoreinput)\n\t\u003e 2 F\tf    mch_delay\t\tos_msdos.c\n\t\t\tmch_delay(msec, ignoreinput)\n\t  3 F\tf    mch_delay\t\tos_unix.c\n\t\t\tmch_delay(msec, ignoreinput)\n\tEnter nr of choice (\u003cCR\u003e to abort):\n```\n\nAnd you have to choose one of them, this is very annoying and disturbing when you are focusing on editing or navigating the sources.\n\nYou don't need to care about this anymore when you use `:PreviewTag` with a new tag name, the first match will be displayed in the preview window, execute `:PreviewTag` with the same tag name again, the next match will be used. If there is no more result, the first one is used again.\n\nWhen you get multiple matches, the current match will be displayed in the command line. `(1/2)` represents there are two tags matched and this is the first one. Assume that you bind `:PreviewTag` to `F3`, all your need is move the cursor on an identifier and repeatly press `F3`, and all the matches will be displayed on the right preview window circularly.\n\nIn the past, scrolling the preview window may involve mode change and window switching. If the preview window is not height enough to view the whole function implementation, you must jump to the preview window press CTRL+F to scroll down then jump back. Leaving and Re-entering insert mode may also be required.\n\n```VimL\nnoremap \u003cm-u\u003e :PreviewScroll -1\u003ccr\u003e\nnoremap \u003cm-d\u003e :PreviewScroll +1\u003ccr\u003e\ninoremap \u003cm-u\u003e \u003cc-\\\u003e\u003cc-o\u003e:PreviewScroll -1\u003ccr\u003e\ninoremap \u003cm-d\u003e \u003cc-\\\u003e\u003cc-o\u003e:PreviewScroll +1\u003ccr\u003e\n```\n\nWith the keymaps above, you can use `\u003cm-u\u003e` and `\u003cm-d\u003e` directly to scroll preview window  without switching window or leaving insert mode.\n\nWhen you are done, press `CTRL+w z` to close the preview window or `:PreviewGoto` to open the previewing file and location in a non-preview window.\n\n\n## PreviewFile\n\nOpen arbitrary file in the preview window:\n\n```VimL\nPreviewFile [++opt] [+cmd] filename\n```\n\nJust like `PreviewTag` but preview a given file, the `+cmd` could be any vim command which will be executed after opening the file. For example:\n\n```VimL\nPreviewFile +:10 ~/.vimrc\n```\n\nThis will open `.vimrc` in the preview window and jump to line 10.\n\n```VimL\nPreviewFile ++nohl +:10 ~/.vimrc\n```\n\nThis will do the same without highlighting line 10.\n\n\n\n## PreviewGoto\n\nWhen you want to open the current previewing tag in a non-preview window you can use:\n\n```VimL\nPreviewGoto action\n```\n\nThe `action` can be either `edit`, `split`, `vsplit` or `tabe`.\n\n\n## PreviewClose\n\nClose the preview window\n\n```VimL\nPreviewClose\n```\nA command version of `CTRL+W z`.\n\n\n## PreviewQuickfix\n\nThis command can preview files listed in quickfix window without opening it directly.\n\n```VimL\nPreviewQuickfix [linenr]\n```\n\nThe `[linenr]` parameter is the line number in the quickfix window. The current line number in the quickfix window will be taken if it is not provided.\n\n```VimL\nautocmd FileType qf nnoremap \u003csilent\u003e\u003cbuffer\u003e p :PreviewQuickfix\u003ccr\u003e\nautocmd FileType qf nnoremap \u003csilent\u003e\u003cbuffer\u003e P :PreviewClose\u003ccr\u003e\n```\n\nWe can have the above keymap in quickfix window for convenience.\n\n![](doc/preview-quickfix.png)\n\nNow we switch to quickfix window and press p, the item under cursor will be displayed in the preview window immediately, then move around the cursor choose another item and press p again, all files is displayed in the same preview window.\n\nIt will not open new split or switch away your current buffer no matter what `switchbuf` is. When you finished, just use `P` (upper case) or `CTRL+W z` to close the preview window.\n\n\n## PreviewSignature\n\nPreview the function signature circularly in the command line:\n\n```VimL\nPreviewSignature[!] [function name]\n```\n\nIf the `function name` is not provided, current word under cursor will be taken as `function name`. If bang `!` sign is given, the nearest function name to the cursor position is chosen.\n\n\n![](doc/preview-signature.png)\n\nFunction signature is displayed at the bottom including file name and line number. Execute `PreviewSignature` again, the next signature will be displayed if there are multiple matches, just like `PreviewTag`.\n\nCalling `PreviewSignature` without any argument will use the current word under cursor as the function name and `PreviewSignature!` will find a function name closest to the cursor position.\n\nThe bang sign is very useful, think that:\n\n```text\nprintf(\u003ccursor position\u003e\n```\n\nWhen you input `printf(` and you can't remember the parameters, you can execute `PreviewSignature!` directly in the insert mode. The cursor is on the right side of left paren the function name `printf` is on the left side, but with the bang sign, function name `printf` can be find out because it is the nearest function name to the cursor position.\n\nNow we have the below setting:\n\n```VimL\nnoremap \u003cF4\u003e :PreviewSignature!\u003ccr\u003e\ninoremap \u003cF4\u003e \u003cc-\\\u003e\u003cc-o\u003e:PreviewSignature!\u003ccr\u003e\n```\n\nThen we can have F4 to display the signature of `printf` even if we typed a `(`. And signatures can be displayed automatically by using `CursorMovedI` autocommands or remapping `(` in insert mode.\n\nF4 can be pressed multiple times until you find the right signature when you got multiple results. Remember to `set noshowmode` before this, displaying signature in insert mode requires turn off `showmode` option. \n\n\n# Requirements\n\nWhen you are generating tags file, the `n` and `S` fields are required:\n\n```bash\nctags --fields=+nS\n```\n\n`n` will tell ctags add a `line number` filed in each tag record and `S` means including function signatures.\n\n`vim-preview` can work fine without these two fields but it can't tell you line number in the command line and it will guess the function signature which may get an incorrect result sometimes. \n\n# Tips\n\nDon't generate tags file manually, use some tags manager like [gutentags](https://github.com/ludovicchabant/vim-gutentags) and [gen_tags](https://github.com/jsfaint/gen_tags.vim). They will take good care of your tags files.\n\nWhen you are using Language Servers with [LanguageClient-neovim](https://github.com/autozimu/LanguageClient-neovim), You can use `PreviewFile` to preview definition instead of  jump to it:\n\n```VimL\ncall LanguageClient#textDocument_definition({'gotoCmd':'PreviewFile'})\n```\n\nYour current buffer will not be switched away, and just close the preview window by `CTRL+W z` when you are done.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskywind3000%2Fvim-preview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskywind3000%2Fvim-preview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskywind3000%2Fvim-preview/lists"}