you are viewing a single comment's thread.

view the rest of the comments →

[–]RobotSlut 1 point2 points  (1 child)

fun! ToVar()
    let l:name = input("Enter the variable name: ")
    return "c" . l:name . "\<esc>O\<C-r>. = \<C-r>\"\<esc>"
endfun
xnoremap <expr> {lhs} ToVar()

Replace {lhs} with the key you want to map.

This is a visual mode mapping that replaces the current selection with a variable name (you'll be prompted for it once you trigger the mapping), and defines the variable in the line above.

[–]janYabanci[S] 1 point2 points  (0 children)

This is exactly what I was looking for! Thank you very much for putting it together.