Ok, thank you very much, it's works now :-)
But I have another little problem, if, always for example, I put let
lineString="\r".substitute(lineString, '\(\w\+\)\(\s\+\)\(\w\+\)','\3\2\1',
'g') or change the \r by \n or \r\n or \n\r (always between double quote
;-)) Vim add ^M or ^@
Note : always in a function, not a map with a single line
Thanks
----- Original Message -----
From: "Yakov Lerner" <[EMAIL PROTECTED]>
To: "Sylvain" <[EMAIL PROTECTED]>
Cc: <vim@vim.org>
Sent: Thursday, June 15, 2006 3:39 PM
Subject: Re: ***SPAM*** Problem with regexp in macro
On 6/15/06, Sylvain <[EMAIL PROTECTED]> wrote:
For example, consider this regexp :
s:\(\w\+\)\(\s\+\)\(\w\+\):\3\2\1:
It swap 2 first words on a line, if we test it, it's works..
Now I want to make a function to do this job so I put in my .vimrc :
map <F7> :call Swap2Words()<CR>
function! Swap2Words()
let lineNumber=line(".")
let lineString=getline(lineNumber)
let lineString=substitute(lineString, "\(\w\+\)\(\s\+\)\(\w\+\)",
"\3\2\1", "g")
You need single quotes here (apostrophes '...') not double quotes.
Double quotes srew the backslashes inside. SIngle quotes
preserve backslashes which is what you want.
Yakov