This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
In vim is there a way to delete without putting text in the register?
Most of the time, I use yy to yank and line and then paste with p somewhere. However, if I use dd to delete any line, or dw to delete any word, I will lose anything that I had yanked. Is there a workaround to this problem?
Thanks,
The same question has been answered a few times, I think.
You can map the correct command to eg <leader>d with:
nnoremap <leader>d "_d
Related
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
This question already has answers here:
How to go to the last edit location across all buffers in vim?
(3 answers)
Closed 7 years ago.
Is there a good command that will switch to the last buffer (and place) where an edit was made? I would prefer not to have to install a plugin just for this (but if there is no other way then I would).
This is not solved by the BufSurf plugin which actually goes back through the navigation history which was the answer to a question that sounds similar.
The previous buffer can be accessed via the alternate file: <C-^> or :e #.
gi / `^ go back to the last edit location in the current buffer.
Unfortunately, there's no command that combines both (but I personally have never missed that).
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 an answer here:
Closed 11 years ago.
Possible Duplicate:
When navigating through word-wrapped text in VIM, how to make the selector move onto wrapped line sections?
Hi all,
I'm editing some source files with large chunks of text and lines that wrap in my terminal. If I want to move down one "line" as I see it in the terminal, I can't press 'j' as this will jump to the next carriage return. So I end up holding down 'w' until I'm where I want to be. This seems dumb to me.
Is there some way someone knows to achieve what I want? Something akin to 'l80' which would give me what I'm after so long as my terminal is displaying 80 columns, but wouldn't work as soon as the number of columns in the terminal changes. Nor would it jump the real lines when it hits them.
Thanyou
Use gj and gk to move up and down within a wrapped line.
A lot of people map:
nnoremap j gj
nnoremap k gk
To make this more convenient. It doesn't have any adverse effects.
(If you aren't familiar with customizing Vim, you can just put those two lines in ~/.vimrc, and restart, and it should behave like you want it to.)
This question already has answers here:
How to redefine a command in Vim?
(3 answers)
Closed 9 years ago.
The default behaviour of :help in Vim opens the help in a horizontal split.
I need to remap :help to instead execute :tab help as to always open the help in a new tab.
How can I remap this command?
:cabbrev help tab help