Set vi as editor in GHCi
Asked Answered
G

2

23

How can I get vi editing mode to work in GHCi?

I'm using version 7.10.3.

I tried Prelude> :set editor vi, but to no effect.

I also have these lines in my ~/.inputrc.

set editing-mode vi
set keymap vi

.

Gyroscope answered 9/3, 2016 at 1:18 Comment(5)
After you :set editor vi, what happens when you try to :edit a file? What do you mean "to no effect"?Pancreatin
I do not mean to edit a file. "To no effect" means I can't get vi editing mode to work in GHCi, like it does not work when I press ESC to get into command mode to navigate/edit a text. In Bash shell i can do it.Midpoint
Possible duplicate of How to customize the readline keybindings of ghciWineskin
there is some VI editing mode in GHCi? ... Or are you talking about setting up some GHCi REPL support for VI?Analcite
@Carsten yes there isMidpoint
R
37

GHCi now uses the Haskeline library for command line editing (which has been true for quite a while now), and it does indeed have a vi mode. The configuration file is ~/.haskeline and the line you want is:

editMode: Vi

Documented here: https://github.com/judah/haskeline/wiki/UserPreferences

Returnee answered 9/3, 2016 at 5:25 Comment(2)
I've just started using it and I noticed that the ; and , commands to repeat f or F commands in one or the other direction do not work...Spermiogenesis
Issue #60 on GitHub is just about this.Spermiogenesis
T
0

This works without any issues on MacOS with The Glorious Glasgow Haskell Compilation System, version 9.4.3

ghci> :set editor vi
ghci> :edit <yourfilename>
Titer answered 20/1, 2023 at 11:11 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.