I'm stuck up with a weird problem. I am trying to copy(yy) and paste(p) a line from one file to another (in split screen). It doesn't look it its working. However, yy, p works in the same file and with another file opened in another "tab". Would be really helpful if someone could tell me how to fix this. Spending a lot of time fixing this :(.
Thanks,
Omkar
This worked:
set clipboard=unnamed
You could also use a named buffer. If you yank with "ayy and put with "ap you can yank and put from any buffer to any other buffer in your vim session. You can use any other letter instead of a as the name of the buffer.
Related
I got a new laptop.
And now when i save a file with vim, the file name replace by lowercase name. Any idea on how to solve this? FileName.vhd -> filename.vhd
I don't have this issue with notepad++
Best Regards,
Since I cannot make a comment, I will make an answer instead. This same problem has been solved here: Vim overwrites filename when writing
In short: put set backupcopy=yes in your vimrc, or type :set backupcopy=yes in Vim to only apply it in the current session. This will make saving files ever so slightly slower, but the filename won't be changed.
Today I restarted my vimrc from scratch to try and trim it down.
I use vim-vinegar and use '-' to go up through the file tree a lot.
In my old setup, I have no idea why but 'o' opened the file, entirely in its own split, just like Enter does normally.
I really want 'o' back to open a file. I have no idea how I got it like that but I've been copying and pasting bits of my old vimrc with no luck. Maybe it was in some weird side effect of a plugin?! Who knows?
So the question: how can I map o to Enter in netrw?!
thanks
If anyone gets here because they lost a weird setting for netwr and they couldn't reinstate it (probably because you switched to neovim) then:
you need to setup your ftplugin file.
First, add
filetype plugin on
to your init.vim. Then create a file, something like .config/nvim/after/ftplugin/netrw.vim.
Then put the thing you want, in there. In my case:
nmap <buffer> o <CR>
and hurrah! It worked!
I am a new comer to the vim world, and I have just installed spf13-vim for a quick start. Apart from that I have not touched my .vimrc file.
I mainly use vim to write some python scripts on a remote server, so I have to type 'set ft=python' each time I open a file using vim. I am wondering if it's possible to edit my .vimrc file to make python a default choice of vim.
Another confusing thing is that each time I type a blank in vim, it shows a inverted question mark on my vim screen. I think it's because of some mismatch in file encoding, but I have no more idea about it.
I know it's a stupid question, but right now I can't solve it myself. Any help is appreciated.
Edit:
I have solved the problem of setting python default by write 'set ft=python' to my .vimrc file. (I didn't know contents in .vimrc are commands in vim) But I still don't know how to eliminate the inverted question mark when I typed a blank char, even after I do some search.
Name the buffer you're editing from the start, don't forget the :filetype plugin in your .vimrc and then things will work correctly.
In any way having :set ft=whatever in your .vimrc is twice wrong. First it'll apply to all new sessions opened without a file. Moreover it'll only apply to the first buffer. I.e. it won't work with :new.
I've used Vim for many months now, and I haven't had any problems. But a few days ago something changed and I can't find the cause of this.
When I use y$ to copy a line of a file, and go into another file to paste it here, I get the error E353 nothing in register. This has worked just fine until now.
What could be the cause for something like this?
Does adding the following to your .vimrc file help?
set clipboard+=unnamed
I am a Vim user and sometimes I made several changes in a file but then want to get back to the beginning and have to type :u a lot of times, so I ask you if there is a shortcut to get to the "oldest change"?
Cheers!
Rodrigo Alves Vieira
http://rodrigo3n.com | #rodrigo3n
The keystroke to undo is just u; if you're pressing :u then that's too many keys (although it works, it's four keys instead of one). Usually I would just hold down u and let auto-repeat do the trick (note that Ctrl+R is the opposite of u if you go too far)..
You can reload from the last saved version on disk using :e!.
Does ':e!' (followed by return) work for you? It gets back to the state of the edited file when it was last saved, or when you started if you've not saved yet...
You also have the :earlier command. :help :ea
Using :e! will get you back to the oldest change as saved. Aside from typing just u instead of :u, also see :h undo-redo for help on all the undo commands.
Other options might be use a vim plugin, such as undo_tags.
You know you can use repeat counts on just about any VIM command, right?
My favorite way:
10000u
ten-thousand-undos.
Zips me back in time, usually to where I opened the file. I can see how things USED to be.
then
10000^R
then-thousand-redos
And I'm back at the end again.
You're welcome.