Last active
December 25, 2022 22:04
-
-
Save jamescherti/3651dfc40aac4181f01fffad4095094e to your computer and use it in GitHub Desktop.
Vim: Return the path to viminfo.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| " Language: Vim script | |
| " Description: Return the path to viminfo. | |
| " Author: James Cherti | |
| " URL: https://gist.github.com/jamescherti/3651dfc40aac4181f01fffad4095094e | |
| " License: MIT | |
| function! VimInfoPath() abort | |
| if &viminfofile | |
| return fnamemodify(&viminfofile, ':p') | |
| endif | |
| for l:item in split(&viminfo, ',') | |
| if len(l:item) > 0 && l:item[0] ==# 'n' | |
| return fnamemodify(l:item[1:], ':p') | |
| endif | |
| endfor | |
| " :help viminfo-file-name | |
| if has('win32') && !has('win32unix') | |
| if exists('$HOME') | |
| return fnamemodify($HOME . '\_viminfo', ':p') | |
| elseif exists('$VIM') | |
| return fnamemodify($VIM . '\_viminfo', ':p') | |
| else | |
| return 'c:\_viminfo' | |
| endif | |
| else | |
| return fnamemodify('~/.viminfo', ':p') | |
| endif | |
| endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment