Questions tagged [command-history]
Questions about how Vim records the commands issues by the user and how to customize this behavior.
41
questions
3
votes
2
answers
124
views
How can I reuse parts of the last command / history
I'm looking for a fast and efficient way to re-use the parameters of the last command in a new command. For example, in a Bash shell you can use the $1 placeholder to reuse the 1st argument of the ...
2
votes
0
answers
562
views
Edit history in Neovim
I'd like to edit my command history at ~/.local/share/nvim/shada/main.shada to remove some incorrect commands.
I open the file with nvim main.shada, remove the commands in question, and close the file....
0
votes
2
answers
230
views
Write command history to buffer
I'd like to insert the output from :history into the current buffer or alternatively write it to file. Is this possible?
0
votes
1
answer
61
views
How to use histadd() with a custom function
I've got the following in my vim config:
map <leader>ot :call OT()<cr>
function! OT()
let fname = input("ot: ", "", "file")
let res = system("ot ...
1
vote
0
answers
243
views
Is there a way to list out history of "normal mode command" for vim
We can get history for Ex commands and search with q: and q/ or q?.
What about history for normal mode command (e.g., s, yy, x, dw, etc.)? Am I stuck with :history?
0
votes
0
answers
93
views
Prioritize recently used commands in fzf
I use fzf's :History: a lot to execute previous Vim commands, it's really handy.
I'd like to give Vim commands that I used more recently a better ranking so they appear as the best match when using :...
1
vote
1
answer
222
views
How to search/replace without appending search history?
In a BufWritePre to remove trailing spaces, my function uses a search/replace for \s\+$ over the current buffer. So after saving any buffer, this weird entry \s\+$ shows up in my search history. Is ...
1
vote
2
answers
2k
views
Is there a simple way to persist command history in Vim/Neovim?
Is there an option I can switch on the init.vim config file to let me keep command history between vim sessions?
1
vote
1
answer
214
views
Prevent commands from populating command-line history
I would like some commands to not be registered in the cmdline history. Is there a way to do this? I can't seem to find anything about it in the doc.
The story: I accidentally deleted a file with :...
1
vote
1
answer
76
views
Command history for specific file
Is it possible to find :commands entered while editing a specific file, as opposed to all commands ever typed at the : prompt? Failing that, is it possible to auto-save commands to a separate history ...
1
vote
1
answer
65
views
Does Vim keep track of screen views?
In vim, one could describe the "state" as the position of the cursor, the position of the screen view (ratio of screen viewable above cursor vs below), and the values of all latent variables and file ...
2
votes
2
answers
288
views
vim incremental command history search
In bash you can easily search the current history entries by hitting <C-r> or <C-s>. This search feature is incremental, and once you hit return, you get a bash prompt auto-filled with the ...
2
votes
1
answer
926
views
Is there any way to execute ex command without adding it to the command history?
When I start vim, I always use -s SCRIPT_FILE_NAME option to execute additional commands. In SCRIPT_FILE_NAME, some ex commands are written. Let COMM denote the additional commands in the file. The ...
2
votes
0
answers
35
views
substitute short by long command forms from history on VimLeavePre
How can I edit the : history from a VimLeavePre autocmd? I'd like certain abbreviated command forms to be recorded with their long form in the shada file.
I'm in the habit of using both :tabe {file} ...
0
votes
1
answer
51
views
Why doesn't it find the correct item?
I have tried to use FZF to filter my (last) commands.
The first function works well and retrieves the list of my last commands.
When I select a command, it triggers my HandleCommand function but goes ...
1
vote
0
answers
43
views
How do you remap keys in :history or :highlight?
I use Colemak hnei for nav in normal mode, but my keys default to hjkl when when I'm viewing :history and :highlight. How do I remap these keys?
My guess is that the program may be switching to more....
2
votes
2
answers
2k
views
How to go up to previous command when in terminal mode in Vim 8?
I am new to Vim. I managed to use :terminal and :vertical terminal to have a terminal side by side with my code. This works great, I can move between my code and the terminals. However, how do I go ...
2
votes
1
answer
2k
views
Commands history for vim commandline and :terminal [closed]
I want a way in which we can access a history of commands in terminal mode (and Vim/NeoVim's internal command line), just like in a normal bash terminal; i.e. if I press the up key it will scroll ...
1
vote
1
answer
218
views
Remap Enter in command history edit window only
I currently have <Enter> mapped to :nohlsearch in normal mode. This allows me to leave search highlighting on for all new searches, but easily turn it off when it (soon after usually) becomes a ...
0
votes
1
answer
541
views
Sharing vim commands history across different users and computers
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 ....
2
votes
2
answers
293
views
How to search and replace in the history
Is there a way edit command line or search history?
I have read Is there search and replace history in vim? and tried using q: to open the history and do changes there, but all it seems to be able to ...
1
vote
0
answers
40
views
How to view the command that was just un(re)done
Is it possible to see the sequence of key presses that are undone/redone when using u and Ctrl-r commands?
0
votes
1
answer
358
views
Where are my recent commands stored in Vim?
So I have made about 10/12 substitutions in my current file using %s/longpatternN//g. Unfortunately I have to apply these same substitutions in 10
or more of my files. I can access my last commands ...
1
vote
2
answers
632
views
reverse-i-search à la Bash Ctrl-r
I would like to be able to search through the previous commands starting with : that I entered, using an interactive incremental search, as it is possible in some shells (example: with Ctrl-r in bash)....
5
votes
1
answer
109
views
Open command window dynamically
I am trying to use the command line window in a vimscript.
Unfortunately, the experiment I have with is not good and I am not able to achieve the following:
normal! q:
This should open the command ...
5
votes
2
answers
222
views
Equivalent of !n in bash in vim for ex commands?
I'd like to be able to view the last n commands, similar to the history command in bash, and then be able to execute the nth command similar to the way it is done in bash by using !<command number&...
9
votes
1
answer
198
views
Use backspace to modify the current command in normal mode?
Sometimes when entering a command in normal mode you may make a typo, for example if I intend to type 10dk, I might accidentally start typing 19d.
Since the command has not been completed/committed ...
18
votes
3
answers
912
views
How does vim determine the size of a single "edit" when using "u" and "CTL-R"?
When using u or CTL-R to undo or re-do an edit in vim, I seem to alter chunks of text, not just the most recent keystroke.
What determines the size of the chunk that is considered to be a single ...
7
votes
1
answer
1k
views
How to have endless vim history?
According to h: help:
Use the 'history' option to set the number of lines that are remembered
(default: 20)
I know I can set the number of lines higher, yet is there an "endless" option that ...
0
votes
0
answers
35
views
Cycle through edit command history [duplicate]
In Vim, i can cycle through edit locations with g, and g;, and jump to locations with Ctrl-I and Ctrl-O. Is there any way to similarly cycle through edit commands? This would be something similar to ...
15
votes
3
answers
5k
views
How to further increase cmdline history size?
I have already put the following setting in my .vimrc file:
set history=1000
It's been there for a while, I work in vim on a daily basis, so there have been many commands executed by now. I know ...
8
votes
2
answers
2k
views
Is there a way to share Vim command history?
Can I share Vim command history across instances in real time?
By that I mean what people do in bash this way:
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
That is, ...
8
votes
2
answers
290
views
How to access recently used files by choosing from a list?
I would like to have a keystroke to show a list of recently used files to choose one to edit.
What do I need to provide that?
And related,
How do I manage the history of recently used files ...
133
votes
6
answers
38k
views
How do I jump to the location of my last edit?
I often make changes to the middle of a big file, use gg to jump to the top to check something, and then realize I forgot to set a mark where I was editing. Is there a built-in way to jump to the ...
3
votes
1
answer
2k
views
How to display invoked keystrokes and commands in normal mode? [duplicate]
How I can activate option which will display my pressed keystrokes or executed commands in normal mode on the screen?
Especially it would be good, if it would give a slight info what specific ...
12
votes
1
answer
351
views
Prevent Vim from recording events for certain filetypes
To add to this stackoverflow question, what should one put in their .vimrc to ensure 'private editing' of certain file extensions (e.g. .gpg files).
Without compromising the effectiveness of the ...
59
votes
2
answers
18k
views
How can I view and edit my recording (i.e. recorded macro)?
I'm using complex repeats to record my operations (qq to record, some operations, q to stop) and I did a mistake.
It is possible to see what I've recorded and correct the mistake, instead of doing it ...
13
votes
2
answers
11k
views
Showing command history with showcmd
When using set showcmd Vim shows partial commands in the last line of the screen. For example, in Normal mode when typing the command dt. the last line shows dt and then, when you hit . the command is ...
41
votes
2
answers
4k
views
Can I see the history of key presses in normal mode?
I know that Vim keeps history for ex commands, searches, jump locations, changes, and possibly others.
With showcmd set, Vim also shows you what keys you have entered so far for a normal mode command,...
16
votes
1
answer
1k
views
How is command history resolved between multiple instances of Vim?
Vim keeps a history of ex commands (accessible via :↑ and q:), and that history persists after quitting.
If I run multiple instances of Vim (same user, same home directory), how does Vim arbitrate ...
8
votes
1
answer
5k
views
How to cache file editing history in Vim, that it would not disappear after switching the file?
When I open another file in a Vim session all editing history for the other files disappears.
Is it possible to configure Vim that it would automatically save and restore file editing history when ...