In vim, if I am in search mode by pressing /, I can press Ctrl+p to find my last searched string, and press that combination again to find an even earlier searched string, and so on. I can do the same on commandline in emacs mode.
I want to do the same with less command (i.e., press /, and then press Ctrl+p to find what I searched for previously, and then press Enter to search that term again. Can I do that? How can I do that?
Edit: reworded to make the question clearer.
To browse less search history (~/.lesshst by default, man less and LESSHISTFILE for more):
less a file, for example less ~/.lesshst
type / or ? to search forward or backward or & to show only matching lines (/!, ?! or &! for non-matching)
use up and down arrows ↑ and ↓ to browse the history, press Enter to choose one
n repeats the search, N in reverse direction. To reset the screen after showing only the matching lines with &, type & followed by Enter.
Use / to search forward.
Use ? to search backward.
Use n for the next occurrence of the search item and N for prior occurrence. This works for both forward and backward searches.
And as pointed out in the comments if less history is enabled you can carry your search item across invocations of less.
man less and man lesskey for the details.
Related
I was watching this video (https://www.youtube.com/watch?v=wiRt3mY7Rrw) and at 3m03s the guy went immediately from a blank bash line to this (vlc screenshot with the exact frame):
, with cursor just after the "t" letter, ready to type the rest and enter it.
I could definitely make use of this shortcut, any idead how he did this ?
Once I get the answer and know what it is, I will rephrase this vague title accordingly so people can find this question.
Most probably, it's the TAB, or the TAB TAB shortcut (press the TAB two times, and you get a list). This goes into the directory you're currently in, and expands to the filenames.
I have a big file and I want to remove all the lines that have the word date
For example:
{
date: 10291992
stuff: stuff
...
},
{
date: 02171995
stuff: stuff
...
},
...
So I want to remove all the lines that contains the word date but since each date has a different date, I can't just ctrl f and replace it. I was reading that putting ^.* in the front but it didn't work for me.
I'm currently using Sublime Text 3.
Thanks.
All you need to do is open the Find dialog (Find -> Find...), search for date, hit Find All to select all instances of your search pattern, then select Selection -> Expand Selection to Line. Hit Delete and you're all done.
I tried to follow the accepted answer but found it wasn't working for me: the Expand Selection to Line button was not expanding the selection for all the matched lines.
What did work, though, was to switch to regular expression mode (the *. button on the left of the Find menu) and do a search for
\n.+date.+
replacing it with an empty string. This removes the entire line (i.e., doesn't leave an empty line in its place).
Or faster: highlight date, hit Alt+F3 to Quick Find All, then Ctrl+X twice to delete the line.
Good day,
is there a way to automatically edit the found words using ctrl + f in sublime, without clicking the found word.
its just extra effort if you'll click the word again even though its already high lighted, using a keyboard key would be much easier specially if your always using the search function.
thank you for the tips.
I don't know if this makes things easier for you, but you can simply press Esc when the word is selected, which will bring the focus back to the editor and you can edit the word, and cycle through the next selections using F3 or bring up the find box using Ctrl+F
In Vimperator, press / and do a search. If there are matches, all will be highlighted.
My question is how to clean these highlights in a decent way.
My current approach is to press / again, and type in a random string like "abcdefgh", enter, and press Esc to clean the red warning in command window.
Type the following to quickly clear highlighted text
:noh
or you can toggle it highlight with
:set hls!
The :nohlsearch command will remove the search highlights. You could map this to a key if you use it frequently.
Remaping is awesome and you should do it!
To add to the answers above:
You can remap some of the keys to handle this automatically for you.
e.g. put this to your ~/.vimperatorrc
" adjust search to enable highlight when searching and disable when escape is pressed
noremap n :set hlsearch<return>n
noremap <esc> :noh<return><esc>
Explanation:
noremap - remaps a key sequence without remaping keys.
n key to remap.
:set hlsearch<return>n function we want remap to perform in this case enable highlighting.
This will set highlight on when you click n (for the next search result) and turn it off when you click escape. You can also use / instead of n if you want highlight on when you start search instantly.
When editing code in VS, I typically use Ctrl+G to move to the line number that I want. It would be really nice if there's another keyboard shortcut that would allow me to move to the word that I want on that same line as well regardless of the cursor's position.
Example:
Say, I just moved to this line:
quint32 beamNum; // Number of beams
and say I want to move to the word "Number"
typically I have to press Ctrl+→ a few times (in this case exactly 4) to get to the word that I want. Imho, this is not fast enough.
I did try using Ctrl+F but it doesnt work for all cases because sometimes I want to search backward and if "Search Up" is not checked, it then becomes too slow.
Just wondering if anyone knows of such shortcut, if one exists.
So, Ctrl+G will take you to the first column of the line. Then, you can press Ctrl+I (not an L) to begin an incremental search. Now, start typing the word that you are looking for (case sensitive) and the IDE will move to the first match of what you're typing. Hit Enter to end the incremental search.