0

I would like to open a file and have nvim automatically be in search mode once the file is opened.

I need to find the correct command to use, probably in the form of nvim -c Command file.txt

To clarify, I want to start nvim and be able to start searching by typing in my search string without first pressing '/' to enter search mode.

running nvim -c '/searchString' executes the search immediately and is not what I want

My use case is that I use nvim as a scrollback pager for kitty.

# kitty passes text to nvim via stdinput which i write to a tmp file in /tmp/kitty_scrollback_buffer
# I then open this file with the nvim terminal by catting the file
# is there anyway to then automatically enter command search mode so that nvim is ready to search when i enter a search string (I do not want to type /, i want to be able to search immediately)
exec nvim \
    -u NONE \
    -c "silent! write! /tmp/kitty_scrollback_buffer | terminal cat /tmp/kitty_scrollback_buffer - " \
tg0h
  • 575
  • 5
  • 17

1 Answers1

0

Yeah, you are right there. If you want to search foo in file.txt, run this:

nvim -c "/foo" file.txt
jdhao
  • 24,001
  • 18
  • 134
  • 273
  • ah sorry, I should have been more explicit. I understand that /foo searches for foo immediately, I was wondering if it's possible to enter search mode without executing a search.... eg something like `nvim -c "/"` (unfortunately, I believe the -c syntax always executes the command, while I would prefer not to execute the command as I do not want to exit search mode) – tg0h Aug 11 '22 at 12:18