As noted on community.rstudio.com, it is quite common to remap ↑ to do history search based on the currently typed text in the terminal, via .inputrc. R run in a terminal respects this setting.
In RStudio, tying that up to .intputrc might be problematic (especially on Windows) but I think the following default would be safe + nice:
Ctrl/Cmd+↑ does history search, with whatever is to the left of the cursor on the current line = opens a modal with the history and the possibility to click through the list (i.e. almost the current behaviour, except that it is restricted it to what is to the left of the cursor; this should be inconsequent in most cases but makes it easier to recover from mistakes -- see below).
↑ does history recall = replaces the current command with a command from history, but here also it is restricted to whatever matches what is currently to the left of the cursor. With nothing typed, you get the current behaviour. With something typed you iterate through history, limited to items matching the current text.
For this to work, when the current command line is replaced by a line from history, the cursor should stay in the same place. This does not prevent execution of the code because pressing Enter executes the whole line, no matter where the cursor is.
Example. My history is
foo <- 1
fib <- 2
bar <- 3
Now my prompt looks like this
> f|
where | is the cursor.
Now, Ctrl/Cmd+↑ gives me a modal with
foo <- 1
fib <- 2
and selecting the first (oldest) element of the history fills the command prompt with
> f|oo <- 1
Note the position of the cursor. This way, typing Ctrl/Cmd+↑ again gives me the same options again (because only "f" is to the left of the cursor), which allows me to select a different one in case I clicked wrong.
Typing ↑ replaces the command line with
> f|ib <- 2
instead of > bar <- 3| as it would be the case now. Typing ↑ again gives
> f|oo <- 1
Of course typing ↓ gives back
> f|ib <- 2
I hope this is clear enough. I suppose it is easy enough to explain, less to implement but, well, I am hopeful!
The text was updated successfully, but these errors were encountered:
I understand that fully implementing this feature request may be fairly complicated.
But would it be possible to implement ↑ doing history recall so it only cycles through commands that match what has been typed in so far to the left of the cursor? This would be very useful.
As noted on community.rstudio.com, it is quite common to remap ↑ to do history search based on the currently typed text in the terminal, via
.inputrc. R run in a terminal respects this setting.In RStudio, tying that up to
.intputrcmight be problematic (especially on Windows) but I think the following default would be safe + nice:For this to work, when the current command line is replaced by a line from history, the cursor should stay in the same place. This does not prevent execution of the code because pressing Enter executes the whole line, no matter where the cursor is.
Example. My history is
Now my prompt looks like this
where
|is the cursor.Now, Ctrl/Cmd+↑ gives me a modal with
and selecting the first (oldest) element of the history fills the command prompt with
Note the position of the cursor. This way, typing Ctrl/Cmd+↑ again gives me the same options again (because only "
f" is to the left of the cursor), which allows me to select a different one in case I clicked wrong.Typing ↑ replaces the command line with
instead of
> bar <- 3|as it would be the case now. Typing ↑ again givesOf course typing ↓ gives back
I hope this is clear enough. I suppose it is easy enough to explain, less to implement but, well, I am hopeful!
The text was updated successfully, but these errors were encountered: