4 ms·
Learning vim is easy, I've done it a thousand times! (As Mark Twain might say) This time around I've been keeping a list of the stuff I miss from my usual work
by ridiculous_fish 11y ago
Learning vim is easy, I've done it a thousand times! (As Mark Twain might say)
This time around I've been keeping a list of the stuff I miss from my usual workflow. Here's two of the most maddening:
1. Searching for literal text. Is there a way to avoid having to manually escape special characters?
2. Maintaining cursor position when scrolling. Maybe I want to go look at another part of the file and come back. How can I scroll without it moving my cursor?
As far as I can tell, I'm SOL on both counts.
- fphilipe 11y ago1. /\Vliteral search 2. C-e and C-y as long as the cursor position doesn't move out of the visible area
- deleted 11y ago[deleted]
- mdup 11y ago1. For the mnemonic, "\v" turns on "very magic" where all possibly special characters will have their special meaning without prefixing them with "\". Now, "\V" is just the opposite of "very magic", which is "very not magic", i.e. disable all special characters.
- jkn 11y ago2. Ctrl+o will bring you back to previous locations in many cases (e.g. after a search).
- tomsthumb 11y agoAssuming the stack grows up, ctrl+o moves you down the stack and ctrl-i moves you back up the stack. Pushing occurs on certain evens like searching and using marks. iirc, popping occurs when you push something onto the jump stack when you aren't at the top and the old <next> (ctrl-i) is replaced by the new current location.
- kqr 11y ago2) is generally accomplished with marks. Press m followed by a letter to set a mark where you are, go down to wherever you want, and then you can pop back by pressing ` (backtick) followed by the letter you set for the first mark. If you want to go back and forth, you can set two marks.
- dghf 11y agoPressing `` (backtick twice) will jump you back to the place of your last edit -- unless you've explicitly set another mark in the meantime, in which case it'll send you there instead.
- dghf 11y ago> 1. Searching for literal text. Is there a way to avoid having to manually escape special characters? Put "set nomagic" in your .vimrc. This makes e.g. "." match a literal period/full-stop rather than any character. To get the special behaviour, escape the character: e.g., in nomagic mode, "\." matches any single character. If you only want this behaviour occasionally, putting "\M" at the start of your search will invoke it for that search only: e.g. "/\Mfull.stops.only" will match "full.stops.only" but not "full-stops:only". Even in nomagic mode, a few characters are treated specially, e.g. "$" for end of line. To suppress even these, start your search "\V": e.g., "/\V$1000". N.B., you can't make this behaviour permanent in your .vimrc: you can only invoke it search by search. If you want the full gory details for all of the above, try ":help pattern" in Vim.