edenzik / macvim

Automatically exported from code.google.com/p/macvim
0 stars 0 forks source link

Find and replace newlines inserts null instead of newline #194

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
IMPORTANT! Before creating a new Issue please search the old Issues for 
duplicates.  Also, 
please do not use this page to ask questions, instead post to the vim_mac 
mailing list.  There are 
more people on that list that can answer questions.  Only file an issue if you 
have found a bug.  
(You can safely delete this text now that you have read it and enter an issue 
report.  Thank you 
for taking the time to report new bugs!)

What steps will reproduce the problem?
Create a file with a few lines in it, then issues the command %s/\n/\n\n/ to 
double-space the 
file.  Instead of newlines, you see ^@ which is a null (\0) when you do a 
object-dump (od) of the 
file.

What is the expected output? What do you see instead?
\n and not \0 or ^@

What version of MacVim and OS X are you using (see "MacVim->About MacVim" and  
"Apple 
Menu->About This Mac" menu items, e.g. "Snapshot 40, 10.5.6 Intel")?
10.5.7 Version 7.2 stable 1.2 (33.3)

Please provide any additional information below.

Original issue reported on code.google.com by bumper...@gmail.com on 20 Jul 2009 at 8:49

GoogleCodeExporter commented 9 years ago
This is not a bug.  See

:h s/\n
:h s<CR>

Basically, you have to use the command

%s/\n/^M^M/

where you should hit Ctrl-v Enter where it says ^M

For future reference: please post these kinds of questions to vim_use instead 
of here (you can be certain its 
not MacVim specific simply by popping up Terminal Vim and see that it behaves 
the same).  Thanks!

Original comment by bjorn.winckler@gmail.com on 20 Jul 2009 at 11:59

GoogleCodeExporter commented 9 years ago
Thank you for the help.  This is one of those issues that is terribly hard to 
search on Google since most non-
alpha characters get stripped from searches...  sorry for the trouble.

Original comment by bumper...@gmail.com on 20 Jul 2009 at 7:47

GoogleCodeExporter commented 9 years ago
No worries.  I've gotten to the point where I most of the time know where in 
the Vim help to search which is why 
I found the above references.  But I know it can be hard!  Still, my tip is to 
leaf through the help files every now 
and then -- they contain _lots_ of information.  Anyway, have fun with Vim. :)

Original comment by bjorn.winckler@gmail.com on 20 Jul 2009 at 11:11

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
But you cannot map newline substitutions:

    map ,nl  :%s! !^M!g<CR>

If you execute 

   :map

you will get

   map ,nl :%s! !<CR>!g<CR>

so ^M is converted into <CR>, which, of course,
does not work.

It neither works with terminal- nor macvim.

Original comment by mis...@gmail.com on 11 Oct 2009 at 2:02