Jump to any word like Easymotion in Vim? - xvim

I install Xvim in my Xcode. However, if I want to jump to some word on the screen, I have to jump to that line first then press several "w" to get to it. Or use '/' to find that word then press several "n".
It's quite annoying! Is there a better way to handle this situation?

Related

How do I go to a search phrase in VIM

I've looked at dozens of tutorials, and they all say how to search in Vim, but not how to stay on the search result.
Let's say I'm at the top of the file, and the word cow is on line 700. If I press Esc, then /cow it will show me the word on line 700, and I can of course use n or N. But as soon as I hit Enter, or Esc, or spacebar,... it puts me back at the top of the screen.
Is there a way to search in Vim and then make the cursor go to and stay on that searched word/phrase?
Thank you.
/cow<CR>
is how you move the cursor to the next occurrence of cow in normal mode.
Try again without your config:
$ vim --clean <file with cow on line 700>

How to get delete-button behavior in vim?

When using vim in insert mode (or not using vim at all), pressing the delete-button deletes a character TO THE RIGHT of the cursor. How can I get this behavior in vim when in normal mode?
Pressing x is not the right answer as it deletes the selected character, not the character to the right.
In the Insert mode it's just for you the cursor looks "kinda between characters". But in fact, your computer sees it being right on the character you are deleting.
In the Normal mode you normally have the bar-cursor, so it looks the way it works.
Now, of course, you can remap your "x" to delete the char to the right, but it will only add a confusion. So, please, don't. Train your mind to see the things in the proper light instead.

Jumping between two lines in Sublime Text

Is there a keyboard shortcut to jump between two lines in Sublime Text? Specifically, I want to be able to jump from the line with the cursor to the line that previously held the cursor. I am not looking to swap the lines, just to move the cursor between the two lines that last held the cursor.
There is an option in vim to use `` or '' to jump between lines. I am looking for the exact same functionality but with Sublime.
On Windows you can use ALT+- to Jump Back, and ALT+SHIFT+- to Jump Forward
On Mac the commands are CTRL+- to Jump Back, and CTRL+SHIFT+- to Jump Forward.

How to type the black hole register command "_d in vim?

This must be a really dumb question, but I could not find the answer after spending hours googling it.
I learned from some tutorial that "_d deletes the content into black hole register. But how exactly is the "_d command typed in vim?
In the following example, if I want to delete the first word "example" into black hole register, what are the exact key strokes I need to make? And the same question for deleting the first line into black whole register?
example line 1
example line 2
You also need a motion for the command, so that it knows, what exactly to delete. That can either be a visual selection or a motion command. Starting in normal mode:
To delete the first word (cursor at start of "example"):
"_dw
Select "example", then delete current selection:
vw"_d
Deleting the whole line:
"_dd
You get the idea.

Vim keep cursor location while scrolling

Is there a way to keep the cusror location off-screen in Vim / gVim while scrolling? Similar to many Windows editors.
I know about marks, and do use them. I also know the '.' mark (last edit location), But looking for other ideas.
I'm asking this because sometimes i want to keep the cursor at some location, scroll to another place using the mouse-wheel, and then just press an arow key or something to get me back to that location.
No. vim is a console application, so it doesn't really make sense to have the cursour off-screen (it's possible, but would just be confusing)
An alternative solution, to paraphrase posts from this thread from comp.editors:
Ctrl+o goes to the previous cursor location, Ctrl+i goes to the next (like undo/redo for motions)
Marks seem like the other solution..
Also, use marks. Marks are named by letters. For instance typing ma remembers
the current location under mark a. To jump to the line containing mark a,
type 'a. To the exact location use `a.
Lower-case-letter marks are per-file. Upper-case-letter marks are global;
`A will switch to the file containing mark A, to the exact location.
Basically ma, move around, then `a to jump back.
Another option which Paul suggested,
gi command switches Vim to Insert mode and places cursor in the same position as where Insert mode was stopped last time.
Why don't you split the window, look at what you wanted to look at, and then close the split?
:split
or
:vsplit (if you want to split vertically)
The only similar behavior that I've found in Vim:
zt or zENTER "scroll the screen down as far as possible without moving the cursor"
zb "scroll as far up as possible".
Ctrl+E "scroll one line down, if possible"
Ctrl+Y"scroll one line up, if possible"
Sometimes you can avoid jumping to marks before entering text — gi command switches Vim to Insert mode and places cursor in the same position as where Insert mode was stopped last time.
Google says that the cursor (and therefore current line) must be visible in Vi, so you'll have to use marks.
Also very useful are the '' (2x single quotes) and `` (2x back quotes).
The former jumps back to the line you were prior to the last jump (for instance, a page down).
The latter jumps back to the line and column you were prior to the last jump.

Resources