You should use getpos():
To save you position in a variable:
let save_pos = getpos(".") getpos() takes as argument a mark, here "." represents the current position of your cursor.
And to restore it:
call setpos('.', save_pos) Here the first argument indicate that you will move the mark of the current position of your cursor (hence your current position) and the second is where to put the mark (the position that you saved earlier).
Your function would look like this:
function! DollarSplit() let save_pos = getpos(".") normal! 6|r$ " replaces the 6th caracter in line with a $ call setpos(".", save_pos) endfunction For more details see: :h getpos() and :h setpos()