def cli_bindings():
key_binding_manager = KeyBindingManager(<EOL>enable_open_in_editor=True,<EOL>enable_system_bindings=True,<EOL>enable_auto_suggest_bindings=True,<EOL>enable_search=True,<EOL>enable_abort_and_exit_bindings=True)<EOL>@key_binding_manager.registry.add_binding(Keys.F2)<EOL>def _(event):<EOL><INDENT>"""<STR_LIT>"""<EOL>_logger.debug('<STR_LIT>')<EOL>buf = event.cli.current_buffer<EOL>buf.completer.smart_completion = not buf.completer.smart_completion<EOL><DEDENT>@key_binding_manager.registry.add_binding(Keys.F3)<EOL>def _(event):<EOL><INDENT>"""<STR_LIT>"""<EOL>_logger.debug('<STR_LIT>')<EOL>buf = event.cli.current_buffer<EOL>buf.always_multiline = not buf.always_multiline<EOL><DEDENT>@key_binding_manager.registry.add_binding(Keys.F4)<EOL>def _(event):<EOL><INDENT>"""<STR_LIT>"""<EOL>_logger.debug('<STR_LIT>')<EOL>if event.cli.editing_mode == EditingMode.VI:<EOL><INDENT>event.cli.editing_mode = EditingMode.EMACS<EOL><DEDENT>else:<EOL><INDENT>event.cli.editing_mode = EditingMode.VI<EOL><DEDENT><DEDENT>@key_binding_manager.registry.add_binding(Keys.Tab)<EOL>def _(event):<EOL><INDENT>"""<STR_LIT>"""<EOL>_logger.debug('<STR_LIT>')<EOL>b = event.cli.current_buffer<EOL>if b.complete_state:<EOL><INDENT>b.complete_next()<EOL><DEDENT>else:<EOL><INDENT>event.cli.start_completion(select_first=True)<EOL><DEDENT><DEDENT>@key_binding_manager.registry.add_binding(Keys.ControlSpace)<EOL>def _(event):<EOL><INDENT>"""<STR_LIT>"""<EOL>_logger.debug('<STR_LIT>')<EOL>b = event.cli.current_buffer<EOL>if b.complete_state:<EOL><INDENT>b.complete_next()<EOL><DEDENT>else:<EOL><INDENT>event.cli.start_completion(select_first=False)<EOL><DEDENT><DEDENT>@key_binding_manager.registry.add_binding(Keys.ControlJ, filter=HasSelectedCompletion())<EOL>def _(event):<EOL><INDENT>"""<STR_LIT>"""<EOL>_logger.debug('<STR_LIT>')<EOL>event.current_buffer.complete_state = None<EOL>b = event.cli.current_buffer<EOL>b.complete_state = None<EOL><DEDENT>return key_binding_manager<EOL>
Custom key bindings for cli.