There are some posts about issues with using the "bind -v". It seems it will 
delete all other key bindings and LLDB does a bunch of bindings for custom 
things which you won't want to use. 

> On May 16, 2020, at 10:34 AM, Alvin Ye via lldb-dev <lldb-dev@lists.llvm.org> 
> wrote:
> 
> Hello,
> 
> I'm using LLDB installed as Arch Linux package.
> 
> % lldb -v
> lldb version 10.0.0
> 
> % cat ~/.editrc
> bind -v

> 
> I'm not able to use vi keybindings like j, k cycle through commands in
> the lldb console.

> 
> It would be great if someone could help me with this issue.

So it seems we hardcode to "emacs" key bindings in your EditLine.cpp source 
file in:

lldb/source/Host/common/Editline.cpp

Checkout the Editline::ConfigureEditor(bool multiline) function.

A few things I see:

- We disable EL_EDITMODE because we run multiple editline instances in the same 
program. Not sure if this will affect the editline "vi" mode:

  if (m_editline) {
    // Disable edit mode to stop the terminal from flushing all input during
    // the call to el_end() since we expect to have multiple editline instances
    // in this program.
    el_set(m_editline, EL_EDITMODE, 0);
    el_end(m_editline);
  }


- We use "emacs" by default right now:

  el_set(m_editline, EL_EDITOR, "emacs");

We could add a setting into lldb that would allow you to set this to "vi" mode. 
If you can download the LLDB sources and build with "vi" mode and see if that 
works as you would expect, we could then add a setting or environment variable 
to allow users to modify this.

I would suggest against using "bind -v" as this seems to clear out the many 
many custom key bindings that we add to the lldb editline instances and you 
really don't want to miss out on that. 

If you do, some people online said that there is something that allows you to 
dump all of the current bindings, which you can then put into your ~/.editrc 
file after a "bind -v". One reason to not do this is if newer lldb binaries add 
new bindings, your ~/.editrc file will now be out of date and might miss out on 
new functionality.

So the best option would be the manually add any VI bindings in your ~/.editrc 
and avoid using "bind -v" for now. I customize my bindings manually and make 
sure any bindings are lldb specific:

$ cat ~/.editrc 
lldb:bind '^[[5C' vi-next-word
lldb:bind '^[[5D' vi-prev-word
lldb:bind '^D' ed-delete-next-char
lldb:bind '^B' ed-command
lldb:bind '^P' ed-search-prev-history
lldb:bind '^N' ed-search-next-history

If you end up building LLDB and the modify 'el_set(m_editline, EL_EDITOR, 
"emacs")' to be 'el_set(m_editline, EL_EDITOR, "vi")' and this really helps, 
let us know and we can file a task to add a setting to LLDB so we can allow 
this to be changed.

Greg

> 
> Thanks,
> Alvin
> _______________________________________________
> lldb-dev mailing list
> lldb-dev@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev

_______________________________________________
lldb-dev mailing list
lldb-dev@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev

Reply via email to