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

Long commands aren't horizontally scrollable #577

Closed
4 of 14 tasks
BBCMarkMcDonnell opened this issue May 23, 2016 · 9 comments · Fixed by #3887
Closed
4 of 14 tasks

Long commands aren't horizontally scrollable #577

BBCMarkMcDonnell opened this issue May 23, 2016 · 9 comments · Fixed by #3887

Comments

@BBCMarkMcDonnell
Copy link

  • Category
    • fzf binary
    • fzf-tmux script
    • Key bindings
    • Completion
    • Vim
    • Neovim
    • Etc.
  • OS
    • Linux
    • Mac OS X
    • Windows
    • Etc.
  • Shell
    • bash
    • zsh
    • fish

Long commands aren't horizontally scrollable

I can't seem to be able to scroll horizontally along any results that are longer that my terminal screen. The example image above shows many different curl requests that look the same, but in fact point to different URLs so it's impossible to know which one I want.

@edi9999
Copy link
Contributor

edi9999 commented May 23, 2016

If you start matching on the right, (in your example, by typing "component"), you can view more (but there is no way to bind a key to scroll to the right for you)

@junegunn
Copy link
Owner

@edi9999 Thanks for chiming in.

If you start matching on the right, (in your example, by typing "component"), you can view more

Yes that's what I would do. A large --hscroll-off value in $FZF_CTRL_R_OPTS can definitely help (the default is 10).

But anyway I don't have a great answer to this. Adding support for manual horizontal scrolling is the last thing I want to do as getting it right and implementing a clean, straightforward interface is not going to be trivial (manual scroll vs. auto scroll, short item vs. long item)

When the above trick doesn't work you, you might want to fall back to the original "reverse-search-history" that can display the command in multiple lines by binding it to a different key sequence (e.g. bind '"\C-x\C-r": reverse-search-history'), or simply use CTRL-P or CTRL-N to browse the recent entries on bash.

Closing as "wontfix" (at least for the moment). Thanks.

@Integralist
Copy link

No problem. Thanks for the feedback everyone :-)

@junegunn
Copy link
Owner

With the latest fzf, we have these options:

# always-visible preview window that shows full command
export FZF_CTRL_R_OPTS="--preview 'echo {}' --preview-window down:2"

# hidden by default, made visible on `?`
export FZF_CTRL_R_OPTS="--preview 'echo {}' --preview-window down:3:hidden --bind ?:toggle-preview"

@markmcd
Copy link

markmcd commented Mar 15, 2019

Thanks for sharing @junegunn.

When I tried those options, the command was truncated to the window width, so it didn't provide much value. From some searching it looks like behaviour has changed since you posted your tip.

For anyone looking to do this now, I updated my CTRL_R_OPTS to look like this:

export FZF_CTRL_R_OPTS="--preview 'echo {} |sed -e \"s/^ *\([0-9]*\) *//\" -e \"s/.\\{\$COLUMNS\\}/&\\n/g\"' --preview-window down:3:hidden --bind ?:toggle-preview"

It's the preview window example given above, but it will wrap the command.

If you want some fancy looking line wrap indicator, try this one:

export FZF_CTRL_R_OPTS="--preview 'echo {} |sed -e \"s/^ *\([0-9]*\) *//\" -e \"s/^\\(.\\{,\$COLUMNS\\}\\).*$/\\1/\"; echo {} |sed -e \"s/^ *[0-9]* *//\" -e \"s/^.\\{,\$COLUMNS\\}//g\" -e \"s/.\\{1,\$((COLUMNS-2))\\}/⏎ &\\n/g\"' --preview-window down:5 --bind ?:toggle-preview"```

@gertcuykens
Copy link

gertcuykens commented Mar 27, 2019

Hmm I would like to understand how fzf --hscroll-off 10 vs fzf --hscroll-off 80 is working in this case. I don't see any difference? Thanks (ref: #513)

The following example result the same

yes $({ printf '=%.0s' {1..400} ;  echo "foobar" ; printf '<%.0s' {1..400}; }) | head -n 20 | FZF_DEFAULT_OPTS="" fzf --hscroll-off 10
yes $({ printf '=%.0s' {1..400} ;  echo "foobar" ; printf '<%.0s' {1..400}; }) | head -n 20 | FZF_DEFAULT_OPTS="" fzf --hscroll-off 80

image

@gertcuykens
Copy link

gertcuykens commented Mar 28, 2019

turns out there was a new line after foobar in example above

yes $({ printf '.%.0s' {1..400}; printf 'foobar'; printf '+%.0s' {1..400}; }) | head -n 20 | FZF_DEFAULT_OPTS="" fzf --hscroll-off=800

works

telotortium added a commit to telotortium/fzf that referenced this issue Apr 8, 2019
This makes it possible to see multiple lines of a multi-line command with the C-r keybinding when using `FZF_CTRL_R_OPTS` to provide a multi-line preview window, as done in junegunn#577 (comment).
@nkh
Copy link

nkh commented Oct 17, 2022

@markmcd check the 'fold' command, it does wrapping and also handles breaking at words

@sameedzahoor
Copy link

This feature needs to be implemented. There are so many use cases that are craving for this functionality.

junegunn added a commit that referenced this issue Jun 25, 2024
* `--wrap`
* `--wrap-sign`
* `toggle-wrap`

Close #3619
Close #2236
Close #577
Close #461
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

Successfully merging a pull request may close this issue.

8 participants