Vim copying text


Is there a trick for copying from something like a powerpoint into vi? Every time I try to copy text from something like a powerpoint to vi my spacing gets messed up. I think it has something to do with my .vimrc file. When I renamed it was able to copy it in just fine so can someone please tell me what in my .vimrc is messing it up. Here is my .vimrc so you can take a look at it. Below it is what I am trying to copy into vi.

set nocompatible
set autoindent
set smartindent
set tabstop=4
set shiftwidth=4
set showmatch
set vb t_vb=
set ruler
set nohls
set incsearch
set virtualedit=all
set number
set cmdheight=2
"This command uses unix mode
set ff=unix

"This command uses dos mode
"set ff=dos

#include <iostream>

int main( void )
   int a;
   int b;
   std::cout << "Enter two integers to compute their sum:" << std::endl;

   std::cin >> a;
   std::cin >> b;

   std::cout << "The sum of " << a << " and " << b << " is ";
   std::cout << a + b << std::endl;

   return 0;

Question information

English Edit question
Ubuntu vim Edit question
No assignee Edit question
Last query:
Last reply:
Revision history for this message
mycae (mycae) said :

I would recommend using a program such as astyle to auto-reformat your code.

you can install it from the repositories, then access it through vim by selecting the text you wish to reformat (eg all the bits between { and }, or the whole lot), then issue the command !astyle

this will invoke the astyle program from within vim and feed it the selected text as stdin. The stdout from the process will then replace the selected text -- voila -- instant code beautification

Revision history for this message
mycae (mycae) said :

So the key sequence i would issue would look like this.

place my cursor on { then hit v, then %, then !astyle

Revision history for this message
Andree (dreewill-deactivatedaccount) said :

Try the following:

when in normal mode execute :set paste then press i for the insert mode and paste your stuff. that should help. afterwards you can execute :set nopaste to exit the paste mode again if you want.

Can you help with this problem?

Provide an answer of your own, or ask COKEDUDE for more information if necessary.

To post a message you must log in.