I have configured .dotfiles. Eg. see here https://wiki.archlinux.org/index.php/Dotfiles
So now I can do dgit push or dgit pull on whichever computer I want, and I have all my config files (including .vimrc) with me.
Now I wish to share vim history across all my accounts on different computers. I suppose that there can be many different solutions to this problem.
So far I am doing this manually by storing vim history inside a ~/.vim_history_manual.txt file. I do this by typing exactly this inside gvim (version 8.0.707):
q:ggVGY:q<CR>:e ~/.vim_history_manual.txt<CR>PggVG!sort|uniq<CR>:wq<CR>
These commands followed by a dgit push will make my vim history available on other computers.
I wanted to make it more automatic. However I have never written such advanced functions in gvim :) I started typing in .vimrc this:
function! ExportVimHistoryManually()
...?
endfunction
only to realize that, I suppose, putting these commands there verbatim would not work:
q:ggVGY:q<CR>:e ~/.vim_history_manual.txt<CR>PggVG!sort|uniq<CR>
So could you tell me:
how to solve this problem in general - share vim history across different accounts, using vim / gvim version 8.0.707
or how to solve this problem in particular - how to write this function ExportVimHistoryManually() which I started?
Perhaps then this function could be supplemented by a second function ImportVimHistoryManually() ? Because currently, when I want to check some of my old commands, I open ~/.vim_history_manual.txt file.
or maybe there is some vim plugin for this which I missed?
EDIT: I didn't mention it before, but only now (after seeing B Layer's answer, and earlier discussion) I realized, that it would be most useful when invoked from inside a running vim session. This is because usually I have multiple instances of gvim opened, and the instance which has quit last is overwriting the viminfo file. So it seems to me, that the best way to preserve history of other instances is to export it manually without ever quitting. The other way is to save session then quit, run B Layer's command, then start it again and restore session.
NOTE: I am using devuan linux ascii release.
.viminfo
:sed -n '/# Command Line History/,/^$/p' ~/.viminfo > ~/.vim_history_manual
. Of course, you can run this from vim::!sed -n ...
sed -n '/# Command Line History/,/^$/p' ~/.vim/viminfo | grep -v -e "^|" | sort | uniq
awk 'h==1 && /^[^|]/ { if (/^#/) exit; print; } /# Command Line History/ { h=1; } ~/.viminfo | sort -u'
. It (1) Quits after the history section, not wasting time scanning the remainder of the file, (2) doesn't show the lines starting with|
or the starting# Command Line History
or the ending blank line (3) Uses-u
flag tosort
to do the unique filtering (if your version ofsort
supports that).