paste in vim creates stupid result

34 views
Skip to first unread message

Alexander Dietz

unread,
Oct 5, 2010, 4:17:30 AM10/5/10
to vim...@googlegroups.com
Hi,

I have the following problem with vim. I am trying to copy the following text from an xterm:

# -----------------------------------------------------
def external_call(command):
    """
    Makes an internal call to the shell (with the
    current set environment), wait for completion
    and returns the output and error of the command.
    @param command: command to be executed internally
    @return: a tuple (status, output, error)
    """

into a vim session (by using shift - middle mouse button), but the result is as follows:

# -----------------------------------------------------
def external_call(command):
    """
        Makes an internal call to the shell (with the
            current set environment), wait for completion
                and returns the output and error of the command.
                    @param command: command to be executed internally
                        @return: a tuple (status, output, error)
                            """

which is not what I want! My .vimrc contains the following content:

:set number
:set paste
:set mouse=a

autocmd FileType * set tabstop=2|set shiftwidth=2|set noexpandtab
autocmd FileType python set tabstop=4|set shiftwidth=4|set expandtab
autocmd BufEnter * set ai sw=4 ts=4 sta et fo=croql
set softtabstop=4 " makes the spaces feel like real tabs


Any idea how to change the settings so that the text is correctly inserted into vim?


Thanks
  Alex

John Beckett

unread,
Oct 5, 2010, 5:54:52 AM10/5/10
to vim...@googlegroups.com
Alexander Dietz wrote:
> but the result is as follows:
>
> # -----------------------------------------------------
> def external_call(command):
> """
> Makes an internal call to the shell (with the
> current set environment), wait for completion
> and returns the output and error of the command.
> @param command: command to be executed internally
> @return: a tuple (status, output, error)
> """
>
> which is not what I want! My .vimrc contains the following content:
>
> :set number
> :set paste
> :set mouse=a

Hmmm, you should not have ':set paste' in vimrc (you don't want
it active all the time). You are supposed to use 'pastetoggle'
and press the key you chose before doing a paste, as at:
http://vim.wikia.com/wiki/Toggle_auto-indenting_for_code_paste

I don't see how you would get that problem if 'paste' is set,
but perhaps something has switched it off (use ':set paste?') to
check current value.

John

Alexander Dietz

unread,
Oct 5, 2010, 6:37:54 AM10/5/10
to vim...@googlegroups.com
Hi,


On Tue, Oct 5, 2010 at 11:54, John Beckett <johnb....@gmail.com> wrote:
Alexander Dietz wrote:
> but the result is as follows:
>
> # -----------------------------------------------------
> def external_call(command):
>     """
>         Makes an internal call to the shell (with the
>             current set environment), wait for completion
>                 and returns the output and error of the command.
>                     @param command: command to be executed internally
>                         @return: a tuple (status, output, error)
>                             """
>
> which is not what I want! My .vimrc contains the following content:
>
> :set number
> :set paste
> :set mouse=a

Hmmm, you should not have ':set paste' in vimrc (you don't want
it active all the time).

Removing ':set paste' does not solve this problem. Now I cannot paste text at all !!!

Maybe someone has an idea how to enable text-pasting using the middle button of the mouse and to paste it without having scrambled the text?
 
You are supposed to use 'pastetoggle'
and press the key you chose before doing a paste, as at:
http://vim.wikia.com/wiki/Toggle_auto-indenting_for_code_paste

I don't see how you would get that problem if 'paste' is set,
but perhaps something has switched it off (use ':set paste?') to
check current value.

I have shown you my fill content of my .vimrc. This is all is configured in vim. And I have absolutely no idea how to switch something on or off - I just want to use vim in the most possible user-friendly way (like I would use emacs for example).


Thanks
  Alex


 

John

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Aaron Lewis

unread,
Oct 5, 2010, 4:37:05 AM10/5/10
to vim...@googlegroups.com

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

+1

Experiencing similar problems , i'll had to re-indent everything again
, also wondering if there used to be a solution

> Thanks Alex -- You received this message from the "vim_use"


> maillist. Do not top-post! Type your reply below the text you are
> replying to. For more information, visit
> http://www.vim.org/maillist.php


- --
Best Regards,
Aaron Lewis - PGP: 0xDFE6C29E
Key Server: http://keyserver.veridis.com
Finger Print: 9482 448F C7C3 896C 1DFE 7DD3 2492 A7D0 DFE6 C29E
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.16 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJMquOwAAoJECSSp9Df5sKezSMP/A2WZMGJER2JDHHvPvAjWYbY
EJUogT9PJjOg7PbOvwiEGXESerY/SOa3KY/fKQ8DazJ9wOVmDYAC7UzceB0Ez3DP
eeYXMOXOtEB6dlpuGrCf6PRsDosemFYjLZ0J06fDSdonKaonw+dBA1yQTHKGL6fS
mte0W21HyC1znc4CTN0rBWs4NsAba9mAVlVpi+6ej6X59LgNoKlNlMGBZgtbm0gA
c7LnvI6y4kanvnK96MZj8Azrz3AVe2wPo0FMfJhKhsAkXuOH+Qgh6dzwt4YtJyyK
WCIzZvsEKcOju/iCRvXdwbn4pDfRbeVq/NxUvUTtZjSQgR/fJwNFufrjUPM7O/WS
u60+NJddyqtBQ6t1UyDekuRLaZL9fo0oTN3PkPzPjtuLkIcBn3czMN0XS/lI1NjS
rOsEHrddG1qwjBaC3SGIOrlnEWot+L8LD3gZChozLoLAubgReupNwDvx3aI0zw3M
2nSUwivD+RBm880RITlEEJ4s4Hm0irudVpfH/a2DLAYFv7UjpTVki/NU7TNAYWJ6
Pc9fZvc/TCvapVvUP0LJfwTIOVsKz2OkVW70FOjygpAqfkm/oDXOqjpcTIUyc1wQ
w7Oa+onmgIBJqPT7S16DQgv1cog1kWX9AxHUyksymBfh3eZ2KW3P2jUKNp3HRx3L
cy6VhlJZRgMbatPPdyGf
=VJEs
-----END PGP SIGNATURE-----

Joan Miquel Torres Rigo

unread,
Oct 5, 2010, 10:00:17 AM10/5/10
to vim...@googlegroups.com
2010/10/5 Alexander Dietz <alexand...@googlemail.com>:

>
> Removing ':set paste' does not solve this problem.

Did you try to explicitly execute ':set paste' JUST BEFORE pasting the text?


> Now I cannot paste text
> at all !!!

What?

The result that you pasted before is what must happen when nopaste is
set, but you must be able to paste either in paste and nopaste modes.

:set paste only temporary disables things like autoindent which could
alter the pasted text.


--
Joan Miquel Torres__________________________________
Linux Registered User #164872
http://www.mallorcaweb.net/joanmiquel
BULMA: http://bulma.net http://breu.bulma.net/?l2301

Alexander Dietz

unread,
Oct 5, 2010, 10:02:48 AM10/5/10
to vim...@googlegroups.com
Hi,

On Tue, Oct 5, 2010 at 16:00, Joan Miquel Torres Rigo <joanm...@mallorcaweb.net> wrote:
2010/10/5 Alexander Dietz <alexand...@googlemail.com>:

>
> Removing ':set paste' does not solve this problem.

Did you try to explicitly execute ':set paste' JUST BEFORE pasting the text?

you mean to type the command in vim the way you type a search command?
 


Alex

Joan Miquel Torres Rigo

unread,
Oct 5, 2010, 10:18:31 AM10/5/10
to vim...@googlegroups.com
2010/10/5 Alexander Dietz <alexand...@googlemail.com>:

The way you type any command.

In normal mode, simply type ':set nopaste<enter>'.

Alexander Dietz

unread,
Oct 5, 2010, 10:37:07 AM10/5/10
to vim...@googlegroups.com
Hi,

On Tue, Oct 5, 2010 at 16:18, Joan Miquel Torres Rigo <joanm...@mallorcaweb.net> wrote:
2010/10/5 Alexander Dietz <alexand...@googlemail.com>:
> Hi,
>
> On Tue, Oct 5, 2010 at 16:00, Joan Miquel Torres Rigo
> <joanm...@mallorcaweb.net> wrote:
>
> you mean to type the command in vim the way you type a search command?

The way you type any command.

In normal mode, simply type ':set nopaste<enter>'.

I would like to configure vim in such a way, that I do not need to type a new command each time I copy something, or paste something etc. When you work with e.g. emacs, xterm or a web-broswer edit field, you also do not need to 'type some command' before you are going to paste something. You just click the middle mouse button to paste text, for example.

My question: Is it possible to configure the same way, such that, when in the inserting mode, text can be pasted into the vim text as it can be done with emacs, xterm, webbrowser etc. If that is possible, what exactly do I need to put into my .vimrc.

Please let me know if this was unclear again.


Thanks
  Alex

 


--
Joan Miquel Torres__________________________________
Linux Registered User #164872
http://www.mallorcaweb.net/joanmiquel
BULMA: http://bulma.net http://breu.bulma.net/?l2301

Joan Miquel Torres Rigo

unread,
Oct 5, 2010, 11:37:54 AM10/5/10
to vim...@googlegroups.com
2010/10/5 Alexander Dietz <alexand...@googlemail.com>:
> Hi,
>
> On Tue, Oct 5, 2010 at 16:18, Joan Miquel Torres Rigo
> <joanm...@mallorcaweb.net> wrote:
>>
>> 2010/10/5 Alexander Dietz <alexand...@googlemail.com>:
>> > Hi,
>> >
>> > On Tue, Oct 5, 2010 at 16:00, Joan Miquel Torres Rigo
>> > <joanm...@mallorcaweb.net> wrote:
>> >
>> > you mean to type the command in vim the way you type a search command?
>>
>> The way you type any command.
>>
>> In normal mode, simply type ':set nopaste<enter>'.
>
> I would like to configure vim in such a way, that I do not need to type a
> new command each time I copy something, or paste something etc. When you
> work with e.g. emacs, xterm or a web-broswer edit field, you also do not
> need to 'type some command' before you are going to paste something. You
> just click the middle mouse button to paste text, for example.
>


1. In your first post you said that you have ":set paste" in your
~/.vimrc that obviously not working. Then, if you want to solve the
problem (only if you want, of course) you need to make some tests to
diagnose the cause.

2. You entitled this thread as 'vim creates stupid result'. But this
result is stupid only if you REALLY told vim that you want enter in
paste mode. Otherwise this is VERY smart becouse it helps user to
indent text (also you can switch off this feature with :set
noautoindent).

3. Setting 'paste' mode by default is not a smart decision because you
will lose many good features, but you can do it simply putting 'set
paste' in your ~/.vimrc.

4. If you were simply did the test that I suggested you probably could
see that this workded and think that there must be something wrong in
your ~/.vimrc.

5. While writting (1) and reviewing your first email I see a spurius
':' before each command in your .vimrc which I did'nt adviced first
time because they are correct when commands used in normal mode, but
not in command mode in which is processed vimrc files.

6. There is to many more intelligent and efficient ways to paste data
from other applications (despite if is desktop clipboard or mouse
selection). See :help registers.

7. If you persist in using mouse to paste, you can also map some keys
to :set paste / :set nopaste commands. But also, you can do what you
where trying just removing the spurius ':' at the begining of the 'set
paste' command in your ~/.vimrc (and, of course, of the other commands
in this file if you want they take some effect).

8. Definitively vim is not stupid, but much more smart that you think.
But requires a bit of patience to learn. Only this. But then you can
improve your efficiency up to 4 or 5 times or more simply tunning it.


> My question: Is it possible to configure the same way, such that, when in
> the inserting mode, text can be pasted into the vim text as it can be done
> with emacs, xterm, webbrowser etc. If that is possible, what exactly do I
> need to put into my .vimrc.

You don't need to put nothing: You need to remove the supurius ':' in
your commands.

Benjamin R. Haskell

unread,
Oct 5, 2010, 11:46:42 AM10/5/10
to vim...@googlegroups.com
On Tue, 5 Oct 2010, Joan Miquel Torres Rigo wrote:

> 2010/10/5 Alexander Dietz:
>> Hi,
>>
>> On Tue, Oct 5, 2010 at 16:18, Joan Miquel Torres Rigo wrote:
>>>
>>> 2010/10/5 Alexander Dietz:

1 through 4 = good points.

A better test would be to run, in vim:

:verbose set paste?

That would indicate whether the ':set paste' in .vimrc is being
overridden.


> 5. While writting (1) and reviewing your first email I see a spurius
> ':' before each command in your .vimrc which I did'nt adviced first
> time because they are correct when commands used in normal mode, but
> not in command mode in which is processed vimrc files.

Stylistically, yes, the ':' should be removed, but it doesn't make a
difference for what gets executed.

:set paste
and
set paste

have the same effect in ~/.vimrc.


> 6. There is to many more intelligent and efficient ways to paste data
> from other applications (despite if is desktop clipboard or mouse
> selection). See :help registers.

I disagree with this part. In most web browsers, for example, there's
often no quick keyboard navigation for selecting a specific range of
text. So, it's much quicker to highlight the range with the mouse and
middle-click it into Vim.


> 7. If you persist in using mouse to paste, you can also map some keys
> to :set paste / :set nopaste commands. But also, you can do what you
> where trying just removing the spurius ':' at the begining of the 'set
> paste' command in your ~/.vimrc (and, of course, of the other commands
> in this file if you want they take some effect).
>
> 8. Definitively vim is not stupid, but much more smart that you think.
> But requires a bit of patience to learn. Only this. But then you can
> improve your efficiency up to 4 or 5 times or more simply tunning it.
>
>
>
>
>> My question: Is it possible to configure the same way, such that,
>> when in the inserting mode, text can be pasted into the vim text as
>> it can be done with emacs, xterm, webbrowser etc. If that is
>> possible, what exactly do I need to put into my .vimrc.
>
> You don't need to put nothing: You need to remove the supurius ':' in
> your commands.
>

(See above.)

Benjamin R. Haskell

unread,
Oct 5, 2010, 12:00:23 PM10/5/10
to vim...@googlegroups.com

As mentioned in the thread below, try:

:verbose set paste?

The 'paste' option doesn't "enable" pasting. It means to treat
characters literally, and to not apply formatting options (like 'ai' and
'fo').

Shift+middle-click in xterm "pastes" (as in: sends the characters to
Vim) regardless of Vim's settings. With :set mouse=a, you shouldn't
need to use 'shift-'.

With xterm, you might need to set the '*allowWindowOps' resource (That
was required for me on Gentoo using an at-the-time very new version of
XTerm.). See one of my responses in a previous thread about this
problem:
http://groups.google.com/group/vim_use/browse_thread/thread/bc916d611971d204

--
Best,
Ben

Alexander Dietz

unread,
Oct 5, 2010, 12:02:30 PM10/5/10
to vim...@googlegroups.com
Hi,

I am not sure if understood me correctly. Or I did not understood you.

On Tue, Oct 5, 2010 at 17:37, Joan Miquel Torres Rigo <joanm...@mallorcaweb.net> wrote:
2010/10/5 Alexander Dietz <alexand...@googlemail.com>:
> Hi,
>
> On Tue, Oct 5, 2010 at 16:18, Joan Miquel Torres Rigo
> <joanm...@mallorcaweb.net> wrote:
>>
>> 2010/10/5 Alexander Dietz <alexand...@googlemail.com>:
>> > Hi,
>> >
>> > On Tue, Oct 5, 2010 at 16:00, Joan Miquel Torres Rigo
>> > <joanm...@mallorcaweb.net> wrote:
>> >
>> > you mean to type the command in vim the way you type a search command?
>>
>> The way you type any command.
>>
>> In normal mode, simply type ':set nopaste<enter>'.
>
> I would like to configure vim in such a way, that I do not need to type a
> new command each time I copy something, or paste something etc. When you
> work with e.g. emacs, xterm or a web-broswer edit field, you also do not
> need to 'type some command' before you are going to paste something. You
> just click the middle mouse button to paste text, for example.
>


The above described the behavior I would like to have with vim. Is there something unclear?

 


1. In your first post you said that you have ":set paste" in your
~/.vimrc that obviously not working. Then, if you want to solve the
problem (only if you want, of course) you need to make some tests to
diagnose the cause.

Why should I make tests? I have explicitly shown my complete .vimrc.
 

2. You entitled this thread as 'vim creates stupid result'. But this
result is stupid only if you REALLY told vim that you want enter in
paste mode. Otherwise this is VERY smart becouse it helps user to
indent text (also you can switch off this feature with :set
noautoindent).

Yes, maybe the title of this thread was not well chosen.
 

3. Setting 'paste' mode by default is not a smart decision because you
will lose many good features, but you can do it simply putting 'set
paste' in your ~/.vimrc.

I do not understand what you are trying to say here.
 

4. If you were simply did the test that I suggested you probably could
see that this workded and think that there must be something wrong in
your ~/.vimrc.

As I says before, I have shown my complete .vimrc. I will show it again at the end of the email, so if you are a specialist of .vimrc settings you might see what is wrong in these set of settings.
 

5. While writting (1) and reviewing your first email I see a spurius
':' before each command in your .vimrc which I did'nt adviced first
time because they are correct when commands used in normal mode, but
not in command mode in which is processed vimrc files.


I have removed them all by now.
 
6. There is to many more intelligent and efficient ways to paste data
from other applications (despite if is desktop clipboard or mouse
selection). See :help registers.


That is exactly why I ask my question on this mailing list - I think I have a simple problem which might be not too hard to solve. I am no vim specialist and I absolutely have no time to spend months on understanding all of the possible .vimrc settings - that is why I am requesting help from the vim specialists in this email forum.

 
7. If you persist in using mouse to paste, you can also map some keys
to :set paste / :set nopaste commands. But also, you can do what you
where trying just removing the spurius ':' at the begining of the 'set
paste' command in your ~/.vimrc (and, of course, of the other commands
in this file if you want they take some effect).


When I 'map' a key to ':set paste', does it mean I just need to press that key so that the respective command is executed? This is not one of the desired behaviors I would like to have. Please read that part again.
 
8. Definitively vim is not stupid, but much more smart that you think.
But requires a bit of patience to learn. Only this. But then you can
improve your efficiency up to 4 or 5 times or more simply tunning it.


As I mentioned before, I have no time to spend months to understand all of the intelligent pieces you can do with vim. That is why I have written this email request - otherwise anyone with a vim configuration question just can read the vim documentation and this email forum would become useless.
 



> My question: Is it possible to configure the same way, such that, when in
> the inserting mode, text can be pasted into the vim text as it can be done
> with emacs, xterm, webbrowser etc. If that is possible, what exactly do I
> need to put into my .vimrc.

You don't need to put nothing: You need to remove the supurius ':' in
your commands.

I do not understand your answer. I asked two questions actually. Let me rephrase them:

1. Is it possible to configure vim in .vimrc in such a way, so I can use the mouse as I can use it in e.g. emacs, xterm or a browser edit box? So that I can paste text, which I have copied before by just marking with the mouse, can paste in with the exact same formatting?

2. If the answer to question (1) is yes: How do I set up my .vimrc configuration to get my desired behavior described under (1)

Please let me know if anything is unclear...

To your answer: I removed all the ':' in .vimrc, but when I paste something into vim each line is still intended by another two spaces, which is not what I want. So I guess your help on this issue does not work for me.


Thanks
  Alex


P.S. My current complete .vimrc again, which I have put into this email as follows: I made a 'cat .vimrc, then marked the whole text with the mouse, changed to this browser window, pressed the middle button on the mouse, and the text appears as below, just as I would to have the behavior within vim...



set number
set paste
set mouse=a


Alexander Dietz

unread,
Oct 5, 2010, 12:12:33 PM10/5/10
to vim...@googlegroups.com
Hi,

:verbose set paste?

This command results in the word 'paste' shown at the bottom of the vim window.


The 'paste' option doesn't "enable" pasting.  It means to treat characters literally, and to not apply formatting options (like 'ai' and 'fo').

Shift+middle-click in xterm "pastes" (as in: sends the characters to Vim) regardless of Vim's settings.  With :set mouse=a, you shouldn't need to use 'shift-'.
 
But I do need to use the shift key. It's a fact for me even with 'set mouse=a'.
 

With xterm, you might need to set the '*allowWindowOps' resource (That was required for me on Gentoo using an at-the-time very new version of XTerm.).  See one of my responses in a previous thread about this problem:
http://groups.google.com/group/vim_use/browse_thread/thread/bc916d611971d204


So you mean my problem need some other changes, related to xterm etc? Why do I need that? I just can copy from/to between: emacs, xterms (different computers, different operating systems, does not matter at all), browser edit windows etc...
Maybe you could elaborate that point a bit? It seems that vim is not that smart at all in the end....



Thanks
  Alex
 

--
Best,
Ben

Dan Wierenga

unread,
Oct 5, 2010, 12:46:09 PM10/5/10
to vim...@googlegroups.com
On Tue, Oct 5, 2010 at 1:17 AM, Alexander Dietz <alexand...@googlemail.com> wrote:

autocmd BufEnter * set ai sw=4 ts=4 sta et fo=croql


I sometimes get results like what you described when I have "set ai".

Try this test:
Paste something, and get the result that you call "stupid".
Undo that paste.
Do ":set noai".
Try your paste again and see if it's as you hoped.
I've never quite tracked down why that happens, nor am I that familiar with ":set paste" that the other posters have referenced, as pasting "just works" in the majority of cases for me, and "set noai" takes care of the cases that it doesn't "just work".  I've never really had to research it that much.  :D  

Hope that helps,
Dan

Ryan Williams

unread,
Oct 5, 2010, 12:53:47 PM10/5/10
to vim...@googlegroups.com
On Tue, Oct 5, 2010 at 1:17 AM, Alexander Dietz <alexand...@googlemail.com> wrote:

autocmd BufEnter * set ai sw=4 ts=4 sta et fo=croql


This was confusing for me to read, you may find parsing your .vimrc easier if you convert


autocmd BufEnter * set ai

into

set ai

or even (my favorite)

set autoindent


This way it's easier to actually understand what your .vimrc is doing. I think these three directives are equivalent but someone more qualified than me can correct me if there are differences between them.

Benjamin R. Haskell

unread,
Oct 5, 2010, 1:05:36 PM10/5/10
to vim...@googlegroups.com
[combining forks of the thread]

On Tue, 5 Oct 2010, Alexander Dietz wrote:

> Hi,
>
> I am not sure if understood me correctly. Or I did not understood you.
>

> On Tue, Oct 5, 2010 at 17:37, Joan Miquel Torres Rigo wrote:
>
>> 1. In your first post you said that you have ":set paste" in your
>> ~/.vimrc that obviously not working. Then, if you want to solve the
>> problem (only if you want, of course) you need to make some tests to
>> diagnose the cause.
>>
>
> Why should I make tests? I have explicitly shown my complete .vimrc.

.vimrc is only one source of configuration. If you have any plugins
installed or your distributions global vimrc (in my case
/etc/vim/vimrc), they might make their own changes.


>> 3. Setting 'paste' mode by default is not a smart decision because
>> you will lose many good features, but you can do it simply putting
>> 'set paste' in your ~/.vimrc.
>>
>
> I do not understand what you are trying to say here.

'paste' mode isn't what you seem to think it is. It prevents some of
the features you're setting from working ('autoindent' doesn't
autoindent in 'paste' mode, 'formatoptions' is ignored in 'paste' mode).

See: :help 'paste' for full details. The gist is that paste mode is
designed to work around problems with pasting: in a terminal without
proper mouse support, Vim has no way to tell whether you're pasting with
the mouse or just typing really fast, and even so, Vim has no way to
know that you don't want some of the automatic formatting applied, just
because you're pasting.


>> 4. If you were simply did the test that I suggested you probably
>> could see that this workded and think that there must be something
>> wrong in your ~/.vimrc.
>>
>
> As I says before, I have shown my complete .vimrc. I will show it again at
> the end of the email, so if you are a specialist of .vimrc settings you
> might see what is wrong in these set of settings.
>

> [...]


>
> set number
> set paste
> set mouse=a
>
>
> autocmd FileType * set tabstop=2|set shiftwidth=2|set noexpandtab
> autocmd FileType python set tabstop=4|set shiftwidth=4|set expandtab
> autocmd BufEnter * set ai sw=4 ts=4 sta et fo=croql
> set softtabstop=4 " makes the spaces feel like real tabs
>

Using that exact .vimrc, with shift+middle-click I get stair-stepping.
With Middle-click alone, it works how you want.

If you leave out the 'ai' (autoindent) in the BufEnter autocmd, there's
no stair-stepping, with or without shift. Same with 'si' (smartindent),
which is arguably better.


On Tue, 5 Oct 2010, Alexander Dietz wrote:
>

> On Tue, 5 Oct 2010, Benjamin R. Haskell wrote:
>
> > :verbose set paste?
>
> This command results in the word 'paste' shown at the bottom of the
> vim window.

The '?' is part of the command. ':set paste?' shows the current status
of 'paste'. Adding the 'verbose' should show you where 'paste' was last
set.


> > Shift+middle-click in xterm "pastes" (as in: sends the characters to
> > Vim) regardless of Vim's settings. With :set mouse=a, you shouldn't
> > need to use 'shift-'.
>
> But I do need to use the shift key. It's a fact for me even with 'set
> mouse=a'.

Checking some other features that might affect this. How about:

:verbose set ttymouse? term?


> > With xterm, you might need to set the '*allowWindowOps' resource
> > (That was required for me on Gentoo using an at-the-time very new
> > version of XTerm.). See one of my responses in a previous thread
> > about this problem:
> > http://groups.google.com/group/vim_use/browse_thread/thread/bc916d611971d204
>
> So you mean my problem need some other changes, related to xterm etc?
> Why do I need that? I just can copy from/to between: emacs, xterms
> (different computers, different operating systems, does not matter at
> all), browser edit windows etc... Maybe you could elaborate that
> point a bit?

Due to the long history of how terminal emulators, computers, and mouses
interact, programs can access mouse information in different ways. Full
discussions is beyond the scope of the Vim list. The XTerm change
log[1] lists several changes to allowWindowOps. The other programs you
list might not use the same method that Vim uses to access mouse
information. So, the allowWindowOps option might not matter to them.
For the way vim under xterm uses the mouse, you might need it. The
reason allowWindowOps affects Vim is that (I think) it relies on XTerm's
"bracketed paste mode"[2], which is only available when window ops are
allowed, and can be runtime enabled/disabled via 'paste64' (another X11
Resource for XTerm).

[1] http://invisible-island.net/xterm/xterm.log.html

[2] http://invisible-island.net/xterm/ctlseqs/ctlseqs.txt (search for
bracketed paste mode)


> It seems that vim is not that smart at all in the end....

It's not helpful to keep reïterating that.

--
Best,
Ben

Benjamin R. Haskell

unread,
Oct 5, 2010, 1:13:14 PM10/5/10
to vim...@googlegroups.com
On Tue, 5 Oct 2010, Ryan Williams wrote:

>>
>> On Tue, Oct 5, 2010 at 1:17 AM, Alexander Dietz wrote:
>>
>>>
>>> autocmd BufEnter * set ai sw=4 ts=4 sta et fo=croql
>>>
>>
>
> This was confusing for me to read, you may find parsing your .vimrc
> easier if you convert
>
> autocmd BufEnter * set ai
>
> into
>
> set ai
>
> or even (my favorite)
>
> set autoindent
>
>
> This way it's easier to actually understand what your .vimrc is doing.
> I think these three directives are equivalent but someone more
> qualified than me can correct me if there are differences between
> them.

With the autocommand version, the options get set whenever changing to
a different buffer. If a modeline turns off 'autoindent', it will be
turned back on. If a modeline sets its own 'formatoptions', the autocmd
resets it.

So, there's a difference. Personally, I thought these lines were
weirder:

autocmd FileType * set tabstop=2|set shiftwidth=2|set noexpandtab
autocmd FileType python set tabstop=4|set shiftwidth=4|set expandtab

(Why not combine the 'bar'-delimited ':set' commands?) But either way,
it works the same. Just for reference, fully "compressed":

au FileType * se ts=2 sw=2 noet
au FileType python se ts=4 sw=4 et

--
Best,
Ben

Joan Miquel Torres Rigo

unread,
Oct 5, 2010, 1:15:06 PM10/5/10
to vim...@googlegroups.com
2010/10/5 Alexander Dietz <alexand...@googlemail.com>:
> Hi,

>>


>> 1. In your first post you said that you have ":set paste" in your
>> ~/.vimrc that obviously not working. Then, if you want to solve the
>> problem (only if you want, of course) you need to make some tests to
>> diagnose the cause.
>
> Why should I make tests? I have explicitly shown my complete .vimrc.

Maybe because you are who are experiencing the problem? ;-)


[...]


> As I mentioned before, I have no time to spend months to understand all of
> the intelligent pieces you can do with vim. That is why I have written this

Then imagine how much time we have to spend trying to solve problems
to people who doesn't want to provide required information about ITS
OWN PROBLEM and prefer to write long emails claiming glass-ball
solutions instead of simply type ':set paste' and tell us what
happens.


Cheers.

Joan Miquel Torres Rigo

unread,
Oct 5, 2010, 1:32:17 PM10/5/10
to vim...@googlegroups.com
2010/10/5 Benjamin R. Haskell <v...@benizi.com>:

>> 5. While writting (1) and reviewing your first email I see a spurius ':'
>> before each command in your .vimrc which I did'nt adviced first time because
>> they are correct when commands used in normal mode, but not in command mode
>> in which is processed vimrc files.
>
> Stylistically, yes, the ':' should be removed, but it doesn't make a
> difference for what gets executed.

Oops!

I didn't know that.

Thank you for rectification.

[...]

>> 6. There is to many more intelligent and efficient ways to paste data from
>> other applications (despite if is desktop clipboard or mouse selection). See
>> :help registers.
>
> I disagree with this part.  In most web browsers, for example, there's often
> no quick keyboard navigation for selecting a specific range of text.  So,
> it's much quicker to highlight the range with the mouse and middle-click it
> into Vim.

I'm not sure because I never tryed this, but I think it is possible to
directly paste mouse selection within vim (or I thought to understood
that reading :help gui-selections). But I think this needs some setup.

Anyway I'm not an authority in this question. I rarely paste data from
mouse selection in vim.

>> You don't need to put nothing: You need to remove the supurius ':' in your
>> commands.
>>
>
> (See above.)

(Ack ;-))

Alexander Dietz

unread,
Oct 5, 2010, 2:48:19 PM10/5/10
to vim...@googlegroups.com
Hi Ben,

first of all thank you very much for your detailed answers. I think they are very useful in generally understanding more the way vim works.


With leaving out the 'ai' it seems to work! When I mark text in a xterm or so with the mouse, I can paste it into vim using shift+middle-click. middle-click alone seems to paste in only what I have 'yy'ed before.
 


On Tue, 5 Oct 2010, Alexander Dietz wrote:

On Tue, 5 Oct 2010, Benjamin R. Haskell wrote:

> :verbose set paste?

This command results in the word 'paste' shown at the bottom of the vim window.

The '?' is part of the command.  ':set paste?' shows the current status of 'paste'.  Adding the 'verbose' should show you where 'paste' was last set.



> Shift+middle-click in xterm "pastes" (as in: sends the characters to > Vim) regardless of Vim's settings.  With :set mouse=a, you shouldn't > need to use 'shift-'.

But I do need to use the shift key. It's a fact for me even with 'set mouse=a'.

Checking some other features that might affect this.  How about:

:verbose set ttymouse? term?



> With xterm, you might need to set the '*allowWindowOps' resource > (That was required for me on Gentoo using an at-the-time very new > version of XTerm.).  See one of my responses in a previous thread > about this problem:
> http://groups.google.com/group/vim_use/browse_thread/thread/bc916d611971d204

So you mean my problem need some other changes, related to xterm etc? Why do I need that? I just can copy from/to between: emacs, xterms (different computers, different operating systems, does not matter at all), browser edit windows etc...  Maybe you could elaborate that point a bit?

Due to the long history of how terminal emulators, computers, and mouses interact, programs can access mouse information in different ways.  Full discussions is beyond the scope of the Vim list.  The XTerm change log[1] lists several changes to allowWindowOps.  The other programs you list might not use the same method that Vim uses to access mouse information.  So, the allowWindowOps option might not matter to them. For the way vim under xterm uses the mouse, you might need it.  The reason allowWindowOps affects Vim is that (I think) it relies on XTerm's "bracketed paste mode"[2], which is only available when window ops are allowed, and can be runtime enabled/disabled via 'paste64' (another X11 Resource for XTerm).

[1] http://invisible-island.net/xterm/xterm.log.html

[2] http://invisible-island.net/xterm/ctlseqs/ctlseqs.txt (search for bracketed paste mode)



Maybe you know of some *easy* introduction to vim configurations in which some of the basics are described, at an beginners level?  That might be useful...



Thanks
  Alex
 


It seems that vim is not that smart at all in the end....

It's not helpful to keep reïterating that.

--
Best,
Ben

Andre Majorel

unread,
Oct 5, 2010, 4:44:55 PM10/5/10
to vim...@googlegroups.com
On 2010-10-05 19:32 +0200, Joan Miquel Torres Rigo wrote:

> I'm not sure because I never tryed this, but I think it is possible to
> directly paste mouse selection within vim (or I thought to understood
> that reading :help gui-selections). But I think this needs some setup.

This is what I use. It's far from perfect but it's a start.

:command! -nargs=1 R :normal :set paste<cr>i<cr><esc>k:r <args><cr>:j!<cr>`[k:j!<cr>:set nopaste<cr>`^
nnoremap <f9> :R !xclip -o<cr>
imap <f9> <c-\><c-o><f9>

--
Andr� Majorel http://www.teaser.fr/~amajorel/
Subliminal message : Vim needs arbitrary tab stops.

Reply all
Reply to author
Forward
0 new messages