Added save_xxx snippets

Saving some values in temprary variables is common process in writing
Vim script.  I made snippets for them for DRY.

Added save_xxx snippets
- save_pos
- save_register
- save_options

Followings are examples of them.

    let pos_save = getpos('.')

    call setpos('.', pos_save)

    let save_reg_g = getreg('g')
    let save_regtype_g = getregtype('g')

    call setreg('g', save_reg_g, save_regtype_g)

    let selection_save = &selection
    let &selection =

    let &selection = selection_save
This commit is contained in:
rhysd 2013-09-26 00:55:44 +09:00
parent 4dfd5f92cc
commit 63fc52ad57

View File

@ -183,4 +183,25 @@ abbr lua <<EOF | EOF
${0} ${0}
EOF EOF
snippet save_pos
options head
abbr use pos save
let pos_save = getpos('.')
${0}
call setpos('.', pos_save)
snippet save_register
options head
abbr use register save
let save_reg_$1 = getreg('${1}')
let save_regtype_$1 = getregtype('$1')
${0}
call setreg('$1', save_reg_$1, save_regtype_$1)
snippet save_option
options head
abbr use option save
let $1_save = &${1}
let &$1 = ${2}
${0}
let &$1 = $1_save