Reputation: 307
I frequently find myself searching for paths such as /a/b/c/file.txt
in files (log files, scripts, etc.), using vi editor. This is usually on some server machine, to which I connect using SSH, so I'm looking for solutions which don't require a GUI editor.
It's painful to have to escape all those /
s every time I want to search for string such as a file path.
Is there any alternative to using /
while searching in vi
? Or, is there some setting that will allow me to set this search character to something else? (even if it sets it only for the active session)
I know I can use grep
, but a solution in vi
would be nice.
Upvotes: 1
Views: 134
Reputation: 290445
You can use another delimiter, such as #
:
:s#search#replace#g
Given a file with this content:
hello this is me/you
I type:
:s#me/you#otherthing#g
And now the text is:
hello this is otherthing
Upvotes: 1
Reputation: 1823
You can use the ?
character instead of /
, But the only difference is /
will do a forward search from top to bottom where as ?
will search from last to first line.
Upvotes: 2