{"id":20560913,"url":"https://github.com/aben20807/my_vim","last_synced_at":"2025-08-11T06:37:56.785Z","repository":{"id":107925424,"uuid":"55767725","full_name":"aben20807/my_vim","owner":"aben20807","description":"Using for recording my vim configuration","archived":false,"fork":false,"pushed_at":"2017-10-09T03:30:20.000Z","size":155,"stargazers_count":1,"open_issues_count":4,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-06T07:50:08.410Z","etag":null,"topics":["abbreviations","brackets","cygwin","keymap","vim","vimrc"],"latest_commit_sha":null,"homepage":"https://github.com/aben20807/aben20807.vim","language":"Vim script","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aben20807.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-04-08T09:35:29.000Z","updated_at":"2019-10-07T23:54:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"c5275bf2-da2e-42b6-81c1-663fbd63ef27","html_url":"https://github.com/aben20807/my_vim","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/aben20807/my_vim","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aben20807%2Fmy_vim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aben20807%2Fmy_vim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aben20807%2Fmy_vim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aben20807%2Fmy_vim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aben20807","download_url":"https://codeload.github.com/aben20807/my_vim/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aben20807%2Fmy_vim/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269842756,"owners_count":24484106,"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","status":"online","status_checked_at":"2025-08-11T02:00:10.019Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["abbreviations","brackets","cygwin","keymap","vim","vimrc"],"created_at":"2024-11-16T03:56:17.002Z","updated_at":"2025-08-11T06:37:56.729Z","avatar_url":"https://github.com/aben20807.png","language":"Vim script","funding_links":[],"categories":[],"sub_categories":[],"readme":"Vim 配置整理\n===\n- 環境: Windows 10, Cygwin, Vim8\n\n## Abbreviations (縮寫)\n- 檔案: .vimrc, .vim/after/ftplugin/vim.vim, .vim/after/ftplugin/rust.vim\n- 參考: https://superuser.com/questions/487603/abbreviations-override-in-comments-and-quoted-text\n- 使用 CodeAbbr() 確認是否可以啟動縮寫功能，若為註解或字串不啟動\n- 使用 Eatchar() 吃掉縮寫後的空白或換行字元\n- e.g. 在.vim的檔案打 \"function\" 會自動補全\n\n```vim\n:iab \u003cbuffer\u003e \u003cexpr\u003e function CodeAbbr(\"function\", \"function\n    \\\u003cCR\u003e\n    \\\u003cCR\u003eendfunction\n    \\\u003cUP\u003e\u003cTAB\u003e\n    \\\u003cUP\u003e\u003cESC\u003e$li \u003cC-R\u003e=Eatchar(\\'\\\\m\\\\s\\\\\u003cbar\u003e\\\\r\\')\u003cCR\u003e\n    \\\")\n```\n![Demo](http://imgur.com/t9AjraP.gif)\n\n## Airline-theme (Airline主題)\n- 檔案: .vim/bundle/vim-airline-themes/autoload/airline/themes/ouo.vim\n- 修改了警告、錯誤區塊的顏色\n\n![Demo](http://imgur.com/XcWYhUQ.png)\n\n## Alt key map (Alt鍵的mapping)\n- 檔案: .keymap.vim\n- 貼文: [106.07.19 vim map alt(meta) key](http://aben20807.blogspot.tw/2017/07/1060719-vim-map-altmeta-key.html)\n- 設定後可用 `\u003cM-x\u003e` 來map Alt+x, 其中x 為 a\\~z, A\\~Z, 0\\~9, 還有一些特殊符號像.和/\n\n## Author Information (添加作者資訊)\n- 檔案: .author.vim, .vim/after/ftplugin/\\*.vim\n- 參考:  http://www.gegugu.com/2016/02/11/17175.html\n- 透過 `\u003cF4\u003e` 在文件開頭添加作者、檔案資訊\n- 如果原本就有只會更新日期、檔名，沒有才會新增\n- 請使用 AddTitle() 定義各檔案類型的資訊內容\n- e.g 在 .vim/after/ftplugin/vim.vim 定義如下\n\n```vim\nfunction! AddTitle()\n    call append(0,\"\\\" Author: Huang Po-Hsuan \u003caben20807@gmail.com\u003e\")\n    call append(1,\"\\\" Filename: \".expand(\"%:t\"))\n    call append(2,\"\\\" Last Modified: \".strftime(\"%Y-%m-%d %H:%M:%S\"))\n    call append(3,\"\\\" Vim: enc=utf-8\")\n    call append(4,\"\")\nendfunction\n```\n![Demo](http://imgur.com/m8vj8V7.png)\n\n## Brackets (括號補全)\n- 檔案: .brackets.vim\n- 貼文: [106.07.01 vim 括號自動配對](http://aben20807.blogspot.tw/2017/07/1060701-vim.html)\n\n## Colortheme (vim主題)\n- 檔案: .vim/color/ouo.vim\n- 對應的區塊大部分都在註解裡面了去找吧\n\n## Comment (註解)\n- 檔案: .comment.vim, .vim/after/ftplugin/\\*.vim\n- 請先在各個 ftplugin 的檔案中設定 call CommentFormat(\"\")\n- 使用 `\u003cM-/\u003e` 來註解或取消註解\n- 使用 visual mode 可一次操作多行\n\n![Demo](http://imgur.com/Dwwii0W.gif)\n\n## Compile and Run (編譯執行)\n- 檔案: .vimrc\n- 參考: http://www.edbiji.com/doccenter/showdoc/24/nav/284.html\n- 跳出之前會先關閉 ale\n- 輸出現在時間避免搞混\n- 也可以切換 markdown 預覽\n\n```vim\nmap \u003cF5\u003e :call CompileAndRun()\u003cCR\u003e\n\" save -\u003e close ALE -\u003e print date -\u003e [execute] run -\u003e open ALE\nfunction! CompileAndRun()\n    \" save only when changed\n    execute \"up\"\n    execute \"ALEDisable\"\n    if \u0026filetype == 'markdown'\n        \" markdown preview\n        try\n            \" Stop before starting and handle exception\n            execute \"MarkdownPreviewStop\"\n        catch /^Vim:E492:/\n            execute \"MarkdownPreview\"\n        endtry\n    else\n        \" echo date time\n        silent execute \"!echo\"\n        silent execute \"!echo -e '\\033[31m ╔══════════════════════════════╗' \"\n        silent execute \"!echo -n ' ║ '\"\n        silent execute \"!echo -n `date`\"\n        silent execute \"!echo    ' ║ '\"\n        silent execute \"!echo -e '\\033[31m ╚══════════════════════════════╝' \\033[37m\"\n        \" detect file type\n        if \u0026filetype == 'rust'\n            \" execute \"!rustc % \u0026\u0026 time ./%\u003c \u0026\u0026 rm %\u003c\"\n            execute \"!time cargo run\"\n        elseif \u0026filetype == 'c'\n            execute \"!gcc -std=c11 % -o /tmp/a.out \u0026\u0026 time /tmp/a.out\"\n        elseif \u0026filetype == 'cpp'\n            execute \"!g++ -std=c++11 % -o /tmp/a.out \u0026\u0026 time /tmp/a.out\"\n        elseif \u0026filetype == 'java'\n            execute \"!javac -encoding utf-8 %\"\n            execute \"!time java %\u003c\"\n        elseif \u0026filetype == 'sh'\n            :!%\n        elseif \u0026filetype == 'python'\n            execute \"!time python3 %\"\n        else\n            redraw\n            echohl WarningMsg\n                echo strftime(\"   ❖  不支援  ❖ \")\n            echohl NONE\n        endif\n    endif\n    execute \"ALEEnable\"\nendfunction\n```\n![Demo](http://imgur.com/qiUjtiF.gif)\n![Demo](http://imgur.com/vVX7bKN.png)\n\n## Completion (補全插件)\n- 檔案: .bundles.vim\n- 插件: [maralla/completor.vim](https://github.com/maralla/completor.vim)\n- 插件(forked): [aben20807/completor.vim](https://github.com/aben20807/completor.vim)\n- 在insert mode按 `\u003cF7\u003e` 開關\n\n![Demo](http://imgur.com/RClIhwr.png)\n\n## Indent highlight (縮排顯示插件)\n- 檔案: .bundles.vim\n- 插件: [Yggdroot/indentLine](https://github.com/Yggdroot/indentLine)\n- 按 `\u003cF3\u003e` 開關顯示\n\n```vim\nPlugin 'Yggdroot/indentLine'\nlet g:indentLine_setColors = 0\nlet g:indentLine_char = '┊'\nnnoremap \u003cF3\u003e :IndentLinesToggle\u003cCR\u003e\n```\n\n## Line number (行號)\n- 檔案: .vimrc\n- 混和版本: 目前行使用絕對行，其他行使用相對行\n- 按 `\u003cF2\u003e` 開關顯示\n\n```vim\nnnoremap \u003cF2\u003e :set norelativenumber!\u003cCR\u003e:set nonumber!\u003cCR\u003e\n:set number\n:set relativenumber\n```\n\n## Markdown preview (Markdown預覽插件)\n- 檔案: .bundles.vim\n- 插件: [iamcco/markdown-preview.vim](https://github.com/iamcco/markdown-preview.vim)\n- cygwin 內啟動 chrome 的設定如下\n\n```vim\nlet g:mkdp_path_to_chrome = \"cygstart /chrome.lnk\"\nlet g:mkdp_auto_start = 0\n```\n![Demo](http://imgur.com/Wyp2qvv.png)\n\n## Remove trailing white space (移除空白)\n- 檔案: .vimrc\n- 來源: Vigil `\u003cvim5632@rainslide.net\u003e`\n- 自動在寫檔前把行末空白、文件末空行刪除\n\n```vim\nfunction RemoveTrailingWhitespace()\n    if \u0026ft != \"diff\"\n        let b:curcol = col(\".\")\n        let b:curline = line(\".\")\n        silent! %s/\\s\\+$//\n        silent! %s/\\(\\s*\\n\\)\\+\\%$//\n        call cursor(b:curline, b:curcol)\n    endif\nendfunction\nautocmd BufWritePre * call RemoveTrailingWhitespace()\n```\n\n## Surround (加上括號)\n- 檔案: .surround.vim\n- 如果輸入字元不支援會顯示  ❖  不支援字元 ❖\n- `\u003cM-s\u003ex`: 在光標所在的單字左右加入x, 其中x 為 ' , \" , \\( , \\[ , \\{ , \u003c\n- `\u003cM-s\u003ex`: 在 visual mode 則在選取的左右加入\n- `n\u003cM-s\u003ex`: 加在包含光標以後 n 個單字, n 為整數\n- `\u003cM-d\u003ex`: 若有包在 x 裡面則刪除字元 x\n- `\u003cM-f\u003exy`: 用 y 取代 x\n\n## Terminal (內部終端機插件)\n- 檔案: .bundles.vim\n- 插件: [wkentaro/conque.vim](https://github.com/wkentaro/conque.vim)\n- 按 `\u003cC-t\u003e` 在分屏開啟終端機\n\n```vim\nnnoremap \u003cC-t\u003e :ConqueTermVSplit bash\u003cCR\u003e\n```\n![Demo](http://imgur.com/qsSb7Mh.png)\n\n## Time (顯示時間)\n- 檔案: .keymap.vim\n- 在 normal mode 按 `\u003cM-t\u003e` 就會顯示現在時間\n\n```vim\nfunction! DateAndTime()\n    redraw\n    echohl WarningMsg\n        echo strftime(\"   ❖  現在時間 %H:%M ❖ \")\n    echohl NONE\nendfunction\nnnoremap \u003cM-t\u003e :call DateAndTime()\u003cCR\u003e\n```\n\n![Demo](http://imgur.com/bWHdrLr.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faben20807%2Fmy_vim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faben20807%2Fmy_vim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faben20807%2Fmy_vim/lists"}