So I'm still pretty new to VIM but I've managed so far. I am using python.vim in my syntax folder. But whenever I paste python code from outside into VIM, the indentation is different. VIM syntax makes a tab, that is 8 char wide, but pasted text is 4 whitespaces. You can see it on this pic:
Is the syntax file wrong? Or should I adjust some settings?
That makes the default paste buffer map to X's clipboard. So, if I mark a bit of text in a terminal, I can simply press p to paste it in vim. Similarly, I can yank things in vim (e.g. YY to yank the current line into the buffer) and middle click in any window to paste it.
How to Turn Off Vim Auto Indent. You can also temporarily turn off automatic indenting by typing :set paste in command mode. (:unset paste to turn it back on again.) This is useful — as you might guess from the command name — if you're pasting in chunks of text or code to avoid getting annoying extraneous indents.
How to Turn On Auto Indent in Vim. To automatically indent when editing a file in Vim, enable the auto indenting feature using the :set autoindent flag in command mode: Press Enter, and this will auto-indent the file you are currently editing.
You can use a movement command or up, down, right, and left arrow keys. Press y to copy, or d to cut the selection. Move the cursor to the location where you want to paste the contents. Press P to paste the contents before the cursor, or p to paste it after the cursor.
You may just have vim set to convert spaces to tabs. Try setting:
tabstop=4 shiftwidth=4 expandtab
in your .vimrc. Also, before you paste, just do
:set paste
Then insert, paste, then
:set nopaste
Here is a good writeup on paste mode.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With