This question already has answers here:
Vim: search and highlight but do not jump
(14 answers)
Closed 2 years ago.
I was getting the cursor word as: noremap <leader>h *N, but this moves the screen. What I want is:
Highlights the <cword>; and
Not move the screen, nor the cursor.
Here is my system: Linux, running neovim v0.4.3 with python2&3 support.
OBS: I know about the plugin inkarkat/vim-mark but I got some errors and it is much more than I need.
I tried using the builtin matchadd, but could not enter the <cword> (it interprets the string literally), and within brackets it considered it a regex.
If I understand you correctly, then here is the answer to your question:
ViM: Search and highlight but do not jump
Related
This question already has answers here:
Display Vim intermediate commands
(2 answers)
Closed 9 years ago.
Here's a quote from vimtutor:
Lesson 2.1: DELETION COMMANDS
** Type dw to delete a word. **
1. Press <ESC> to make sure you are in Normal mode.
2. Move the cursor to the line below marked --->.
3. Move the cursor to the beginning of a word that needs to be deleted.
4. Type dw to make the word disappear.
NOTE: The letter d will appear on the last line of the screen as you type
it. Vim is waiting for you to type w . If you see another character
than d you typed something wrong; press <ESC> and start over.
But that NOTE doesn't reflect my experience - the letter 'd' simply doesn't appear (and neither does any other letter). Why is there this inconsistency between vimtutor and my experience?
(vim version 7.4, vimtutor version 1.7)
This is probably an oversight. That feature is governed by the showcmd option which appears to be false while the author of the vimtutor expects it to be true.
You should submit this issue on the vim mailing list.
This question already has answers here:
Vim clear last search highlighting
(32 answers)
Closed 8 years ago.
So for some reason, after copying and pasting text from Sublimetext into VIM, VIM is now auto-highlighting text as I type:
This highlighting persists even when I change the colorscheme (this is with :colorscheme blue)
The only things I can find online about this regard syntax highlighting and search highlighting, not text highlighting - how do I turn this off? I just want my text to output as normal without it being highlighted some weird color.
Try running the command :noh.
This question already has answers here:
Move entire line up and down in Vim
(21 answers)
Closed 9 years ago.
I was wondering which was the shortest way to turn upside down two adjacent lines in vim, for example:
Hi
How are you?
in
How are you?
Hi
Are there some special shortcuts or should I consider to write a macro for this?
Use ddp when your cursor is on the first line.
dd deletes the current line.
p pastes the deleted line under the current one.
What you need is a mapping: what that mapping does, even if it's 20 commands chained, doesn't really matter.
nnoremap <F6> :m-2<CR>==
and
nnoremap <F6> ddp
both do exactly what you want in slightly different ways. One command is complex and relatively smart while the other is simple and relatively dumb but they are equivalent in the way that they are both done with a single keystroke.
Of course you can use somerhing else than F6.
This question already has answers here:
How to display all results of a search in vim
(3 answers)
Closed 9 years ago.
Is it possible in vim to bookmark all search results like in notepad++? i.e. all search results are stored on the bottom window. So it's no needs to search what you are already have searched.
When you search the current buffer via
:vimgrep /{pattern}/ %
instead of /{pattern}, Vim will store the matches in the quickfix list. You can open a window with the results via :copen, and select a match with Enter. This was mainly done for compiler errors, but it's useful for search results, too. The nice thing is (and here comes the answer to your question) that Vim stores the last ten lists, and you can recall them with :colder and :cnewer.
Not sure what 'storing search results' means, but if you type q/in normal mode, you get a pop-up window with your latest searches that you can even edit before executing them again.
I am using the following code to search the word under cursor and to get the list displayed in the quickfix list at the bottom of the screen :
noremap <Leader>g :grep<space><C-r><C-w><CR>:copen<CR>
You can adjust where and what you want to search trough set grepprg in your .vimrc, this is using the system grep rather than the Vim built-in command.
This question already has answers here:
Search for selection in Vim
(6 answers)
Closed 9 years ago.
Okey, the title definitely needs work, but you Vimmers out there, may already have a clue of what I'm aiming at.
I recently found myself using Vim's * function often (pressing the * key to fast forward search for some words). Is there a way to put the current visual selection (usually consisting of two or three words) into with * and then to use the * key to toggle through the buffer for it?
The question body is goona need some work too :-)
You can use a command that comes with the help of vim, it's like:
:vmap X y/<C-R>"<CR>
What does it mean?
With some text selected in visual mode, press X and the map yanks it to the unnamed register (y), begins a search command (/), yanks the content of the unnamed register into the text to search (<C-R>") and begins the search with <CR>. After it you can use the common * to following terms.