> Greetings and Happy Holidays,
>
> I'm a long-time user of vim but new to vim macros.
Welcome to VimL!
There are some help sections you can read.
> Wanting to go a few steps beyond rot13, I'd like to build a macro that implements an affine cipher. I see where vim can do modular arithmetic, so the questions are:
> 1. can vim do char->int and int->char transformations?
Read the following, specially the _Note_:
:h variables
> 2. does vim have some flavor of a for-loop ( for looping over every
> character in a file?
Yes:
:h :for
:for needs a list, check this:
:h split()
e.g.:
let thestring = 'Test'
for i in split(thestring, '\zs')
echo i
endfor
> 3. can vim directly access characters at specific locations? Like
> Like Java's StringBuffer.charAt(int)
> and StringBuffer.setCharAt(int)
Yes, using the form thestring[index]:
:h expr-[]
> perhaps something like creating a sub-function foomagic to handle the transformation then something like
> %s/char/foomagic{char}/
Maybe this:
:h sub-replace-expression
>
> Any suggestions/hints/constructive critisms and especially examples are all welcome.
For an introduction into VimL read:
:h usr_41.txt
For more details:
:h eval.txt
Cheers!
Israel
--
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
No comments:
Post a Comment