Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

where is the : command history stored?

Tags:

vim

I want to know where the : command history is stored for a particular vim session. I know we can scroll and search through the history. My objective is to take a portion of the commands that I executed using trial and error and create a vim source file.

like image 606
xshyamx Avatar asked Apr 20 '09 17:04

xshyamx


People also ask

Where is history command in Linux?

In Linux, there is a very useful command to show you all of the last commands that have been recently used. The command is simply called history, but can also be accessed by looking at your . bash_history in your home folder. By default, the history command will show you the last five hundred commands you have entered.

Where is command history in terminal?

Open a terminal application on your Linux or Unix and type history to list all commands. To search for a command in the history, press ctrl+r multiple times. For instance, you can hit the ctrl+r and type string to search.

Which command keeps history of commands?

In computing, various shells maintain a record of the commands issued by the user during the current session. The history command works with the command history list.

What is command history in Linux?

The history command in Linux is a built-in shell tool that displays a list of commands used in the terminal session. history allows users to reuse any listed command without retyping it.


3 Answers

it is stored at $HOME/.viminfo

From the vim help command:

The viminfo file is used to store:
- The command line history.
- The search string history.
- The input-line history.
- Contents of registers.
- Marks for several files.
- File marks, pointing to locations in files.
- Last search/substitute pattern (for 'n' and '&').
- The buffer list.
- Global variables.
like image 140
Arkaitz Jimenez Avatar answered Sep 26 '22 15:09

Arkaitz Jimenez


You can also open your recent command history in a minibuffer using the q: or :<CTRL-F> commands

 OPEN

 There are two ways to open the command-line window:
 1. From Command-line mode, use the key specified with the 'cedit' option.
    The default is CTRL-F when 'compatible' is not set.
 2. From Normal mode, use the "q:", "q/" or "q?" command.  *q:* *q/* *q?*
    This starts editing an Ex command-line ("q:") or search string ("q/" or
    "q?").  Note that this is not possible while recording is in progress (the
    "q" stops recording then).

 When the window opens it is filled with the command-line history.  The last
 line contains the command as typed so far.  The left column will show a
 character that indicates the type of command-line being edited, see
 |cmdwin-char|.

You can move around this window, and copy just like a normal buffer. Hitting <Enter> over a command will execute it.

like image 25
rampion Avatar answered Sep 23 '22 15:09

rampion


You are looking for the functions histget(), histadd() and histdel().

EDIT: viminfo file will contain history data from several sessions, which I guess, you were already aware of, according to the way you formulated your question.

like image 44
Luc Hermitte Avatar answered Sep 26 '22 15:09

Luc Hermitte