VIM, History and Readline.

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

VIM, History and Readline.

Ayoub890
Hi,
I want to use readline in vi mode but support for vi appears to be
rather limited. It has better support for emacs and I do not want to go
back to using emacs.
Because of its limited support for vi, I want to try and circumvent the
readline and open the command history file directly with VIM. I am using
several xwindows but my login directory has only one ".bash_history"
file. The other history files are probably stored in temporary files.
Can I open them with VIM and grab commands and edit them and thus not be
limited by the inadequate readline support for vi?

The silly and incomplete way of doing it is:

$ history > temporaryfile
$ vim temporaryfile

Shell and Vim gurus can help here. We need Vim to pull the history file,
allow editing/composing of a new command (in full screen mode, not just
in line mode), exiting, issuing the new command to the shell CLI. Also,
the history file must be updated with the new executed command. Does
there exist a way of doing this?

Thanx,

Ayoub890
Reply | Threaded
Open this post in threaded view
|

Re: VIM, History and Readline.

Gary Johnson
On 2005-08-02, Ayoub890 <[hidden email]> wrote:

> Hi,
> I want to use readline in vi mode but support for vi appears to be
> rather limited. It has better support for emacs and I do not want to go
> back to using emacs.
> Because of its limited support for vi, I want to try and circumvent the
> readline and open the command history file directly with VIM. I am using
> several xwindows but my login directory has only one ".bash_history"
> file. The other history files are probably stored in temporary files.
> Can I open them with VIM and grab commands and edit them and thus not be
> limited by the inadequate readline support for vi?
>
> The silly and incomplete way of doing it is:
>
> $ history > temporaryfile
> $ vim temporaryfile
>
> Shell and Vim gurus can help here. We need Vim to pull the history file,
> allow editing/composing of a new command (in full screen mode, not just
> in line mode), exiting, issuing the new command to the shell CLI. Also,
> the history file must be updated with the new executed command. Does
> there exist a way of doing this?

From the shell, the fc command will open a $VISUAL or $EDITOR window
(I forget which--I have both set to vi which really points to vim)
containing the last shell command you executed.  You can then
execute

    :r !history

to load the last n lines of command history into the vim buffer,
edit the buffer to get the command you want, then write the buffer
and quit vim and the shell will execute the command.

HTH,
Gary

--
Gary Johnson                 | Agilent Technologies
[hidden email]     | Wireless Division
                             | Spokane, Washington, USA