Question

I'm aware of that vim is just an editor, but I sometimes want to call bash commands within vim like following:

:!some --long --command -I --do --not --remember

So recalling from history is a vital function for me to edit things. Both of cnoremap <C-p> <Up> and cnoremap <C-n> <Down> are always sitting in my .vimrc.

Now I'm wondering if I can search not only $HOME/.viminfo but also $HOME/.bash_history (with prepending :!).

Can I do like that without vim plugins?

Was it helpful?

Solution

How about making it so that when Vim is launched it will read in ~/.bash_history and append it to the appropriate section in .viminfo (which stores command-history, among other things)? To avoid duplicating the entire Bash history on later launches of Vim you should run a snippet of script to remove duplicate lines.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top