Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I use the tab key as a input for four spaces? #1452

Closed
betapictoris opened this issue Jun 30, 2021 · 2 comments
Closed

How can I use the tab key as a input for four spaces? #1452

betapictoris opened this issue Jun 30, 2021 · 2 comments

Comments

@betapictoris
Copy link

Instead of having the tab key trigger autocomplete how could I instead use it to add four spaces to a multi-line input?

@erasels
Copy link

erasels commented Jul 22, 2021

You can just create a keybind like so:

from prompt_toolkit.shortcuts import prompt
from prompt_toolkit.keys import Keys
import prompt_toolkit.buffer

kb = KeyBindings()

@kb.add(Keys.Tab)
def _(event):
    buff: prompt_toolkit.buffer.Buffer = event.app.current_buffer
    buff.insert_text("    ") 


prompt("Input: ", key_bindings=kb)

@betapictoris
Copy link
Author

Thank you @erasels!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants