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

Question: What is the difference between text_before_cursor and get_word_before_cursor? #823

Closed
tamago324 opened this issue Jan 27, 2019 · 2 comments

Comments

@tamago324
Copy link
Contributor

hi.

Thank you for a wonderful library!

Is there a difference between document.text_before_cursor and document.get_word_before_cursor()?

The difference is "contain" or "not contain" the leading space?

If there is a difference, I would like if there is an example

Thank you

@jonathanslenders
Copy link
Member

Hi @tamago324,

text_before_cursor is the whole text before the cursor, from the very first character until the cursor position.

get_word_before_cursor returns the word before the cursor. Typically the part that would be removed by a Control-W key press in Vi mode (it's not exactly Meta+backspace in Emacs mode). if WORD=True is given, this will take any whitespace as a separator. A different regex pattern can be given in the latest release, if you want a different separator.

Hope this helps,
Jonathan

@tamago324
Copy link
Contributor Author

Hi @jonathanslenders

Thanks to you, I was able to understand the difference between them!

I am also very happy to understand the behavior about the WORD argument of get_word_before_cursor

Also, understanding has deepened by reading the source code here(get_word_before_cursor and find_start_of_previous_word ).

It was easy to understand that the same behavior as i_CTRL-W of vim was.

Thank you very much.

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