Hi Thomas,
On Mon, May 11, at 07:02 Thomas Allen wrote:
>
> I map <S-CR> to this little script in my various ftplugin files to
> make adding line endings easier. ":" for Python, ";" for C-style
> languages, etc. Now I want to use it for Erlang, for which "." seems
> reasonable.
>
> " Insert a line ending if necessary
> fun! AddLineEnder(char)
> let line = getline(".")
> if match(line, a:char . "\s*$") == -1
> exec "normal A" . a:char
> endif
> endfunction
Use the escape() function, like this (I added also the backslash to the
example):
if match(line, escape(a:char, '.\') . "\s*$") == -1
> :call AddLineEnder(".")
If you ever want to add a backslash however, you have to enter two of
them inside double quotes, or one by using single quotes.
> Thomas
Regards,
Agathoklis.
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---