Hi Ti,
I've removed the mapping that was misusing the default vim <C-R> behaviour.When I now do:
:call SRT_CorrectNames()
- I see my input list transformed to a joined line with \| between the words
- I see that I move to my file where I want to do substitution.
- I now get an error on the substitute
- I now get an error on the substitute
E486: pattern not found : \c\<\(<C-R>0\)\>
Any idea why pattern isn't found?
function! SRT_CorrectNames()
:sp input.txt
:%s/$/\\|/
:%j!
":s/..$
execute "normal! \<end>xx"
"0y$
let @0 = getline(1)
di 0
"
:wincmd w
%s/\c\<\(<C-R>0\)\>/\u&/g
" " substitute across the entire file (":%s/")
" " ignoring case ("\c")
" " a word must start here to match ("\<")
" " start the list of alternatives ("\(")
" " use control+R followed by zero
" " to include the word-list joined by \|
" " that we yanked previously
" " close the list of alternatives ("\)")
" " ensure that the word ends here ("\>")
" " and replace it with ("/")
" " the next letter uppercased ("\u")
" " the text we captured ("&")
" " and do all replacements on the line ("/g")
"
"This assumes that your input list is all just whole words, no funky
"regexp metachars (periods, backslashes, asterisks, or
"open-square-brackets come to mind).endfunction
endfunction
Rgds,
Jeri
Jeri
On Wed, Apr 23, 2014 at 7:58 PM, Jeri Raye <jeri.raye@gmail.com> wrote:
Hi Tim,
I'm trying to make a function out of your commands.
Perhaps that that is the reason why it's not working straight away.
Rgds, JeriOn Mon, Apr 21, 2014 at 4:42 PM, Tim Chase <vim@tim.thechases.com> wrote:On 2014-04-21 08:37, Jeri Raye wrote:This should work on all versions of vim, regardless of operating
> :s/..$
> doesn't work at my windows system
> I use:
> execute "normal! \<end>xx"
system. How are you determining that it isn't working? Is it giving
you an error? Is it not removing the last two characters (the "\|")
from the line? If you are having a problem, you could tweak the
first couple steps to
:1,$-s/$/\\|/
which will tack them onto every line *except* the last one, saving
you that ":s/..$/" step.
This sounds like you're trying to do this in some mode that isn't
> Then it fails on
> 0y$
>
> I get the error message E488: Trailing characters
normal-mode. Perhaps command-mode?
You could yank the entire line and then just remove the newline at
the end if that's easier.
You mean...other than not remapping away something that is incredibly
> I also noticed that the <C-R> mapping in the last substitute
> command is already used in another plugin.
> Is there a workaround for?
valuable? ;-) You can always map something else to it:
:cnoremap <f4> <c-r>
-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
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment