Quantcast

It works but it doesn't work

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

It works but it doesn't work

howard Schwartz
I've got two simple ex commands in a larger script. When I run them on the
file, direct from the ex command line, they work fine. When I run them from
the script, they do not work. Even If I simply jut put the commands below in
a simple script file, script.vim, enter my main file and execute

:source script.vim <ENTER>

The commands do not do their job on the file. Why would they work, if run
directly, but not, if run within a script?

   set wrapscan
   "wrap long lines
   g/^.\{80,}$/gqgq
   "join hyphnated words at end of lines
   g/[^-]-\n/s/-\n\([^ ]*\)/\1 /



--
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: It works but it doesn't work

Jürgen Krämer-4

Hi,

howard Schwartz wrote:

> I've got two simple ex commands in a larger script. When I run them on the
> file, direct from the ex command line, they work fine. When I run them from
> the script, they do not work. Even If I simply jut put the commands below in
> a simple script file, script.vim, enter my main file and execute
>
> :source script.vim <ENTER>
>
> The commands do not do their job on the file. Why would they work, if run
> directly, but not, if run within a script?
>
>    set wrapscan
>    "wrap long lines

did you really mean wrapscan? From you comment it seems you wanted ot

     set wrap

>    g/^.\{80,}$/gqgq
>    "join hyphnated words at end of lines
>    g/[^-]-\n/s/-\n\([^ ]*\)/\1 /

Regards,
Jürgen

--
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us.     (Calvin)

--
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: It works but it doesn't work

Gary Johnson-4
In reply to this post by howard Schwartz
On 2012-06-28, howard Schwartz wrote:

> I've got two simple ex commands in a larger script. When I run them
> on the file, direct from the ex command line, they work fine. When I
> run them from the script, they do not work. Even If I simply jut put
> the commands below in
> a simple script file, script.vim, enter my main file and execute
>
> :source script.vim <ENTER>
>
> The commands do not do their job on the file. Why would they work, if run
> directly, but not, if run within a script?
>
>   set wrapscan
>   "wrap long lines
>   g/^.\{80,}$/gqgq
>   "join hyphnated words at end of lines
>   g/[^-]-\n/s/-\n\([^ ]*\)/\1 /

If you're using Windows, it could be that you are saving script.vim
with the DOS file format, i.e., with carriage-return/line-feed line
endings.  When Vim sources such a file, it sees the carriage returns
at the ends of the lines as part of the lines and not as part of the
line terminators.

Open script.vim and execute

    :set ff?

to determine the file format.  If it's "dos", that could be the
problem.  Execute

    :set ff=unix
    :w

to get rid of those carriage returns, then try sourcing your script
again.

HTH,
Gary

--
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: It works but it doesn't work

Ben Fritz
On Friday, June 29, 2012 2:05:44 AM UTC-5, Gary Johnson wrote:
>
> If you're using Windows, it could be that you are saving script.vim
> with the DOS file format, i.e., with carriage-return/line-feed line
> endings.  When Vim sources such a file, it sees the carriage returns
> at the ends of the lines as part of the lines and not as part of the
> line terminators.
>

Native Windows Vim sources scripts with DOS fileformat without any problems.

The problem with sourcing these scripts is on Unix Vim or maybe cygwin Vim.

--
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: It works but it doesn't work

Tim Chase
In reply to this post by howard Schwartz
On 06/29/12 01:10, howard Schwartz wrote:
>    "wrap long lines
>    g/^.\{80,}$/gqgq

Are you sure you don't need a "normal" in there?

  g/^.\{80,}$/norm gqq

-tim



--
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: It works but it doesn't work

howard Schwartz
Yes, I often seem to make simple mistakes when typing to the vim group. The
command should be:

  g/^.\{80,}$/normal gqgq

I discovered the problem. The text I run the script is converted, with
software from a complex PDF file. It includes very long lines as well as
hyphenated lines that are both long (over 80 characters) and short.

I made the script work by setting textwidth=2000 before executing the
command that gets rid of the hyphens, and then resetting it to 75 when I ran
the formatting command that shortens long lines.

Apparently, the hyphen command, which included an EOL character (\n) did not
work on lines that were longer than the value of textwidth.

It took a while to realize that the value of textwidth would affect this
command.


On Fri, 29 Jun 2012, Tim Chase wrote:

> On 06/29/12 01:10, howard Schwartz wrote:
>>    "wrap long lines
>>    g/^.\{80,}$/gqgq
>
> Are you sure you don't need a "normal" in there?
>
>  g/^.\{80,}$/norm gqq
>
> -tim
>
>
>
>

--
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: It works but it doesn't work

Tim Chase
On 06/29/12 16:27, howard Schwartz wrote:
> I discovered the problem.

I should have double-checked (I changed domain registrars and my
domain was messed up for the last 24hr or so.  Ditched GoDaddy to
1&1, but unhappy with how 1&1 handled the DNS transfer </gripe>)
before I resynced my mail online or I would have seen the other
replies where it looks like everything got sorted out.  Glad you got
things working.

-tim


--
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
Loading...