aboutsummaryrefslogtreecommitdiff
path: root/vim/bundle/tlib_vim/autoload/tlib/normal.vim
diff options
context:
space:
mode:
Diffstat (limited to 'vim/bundle/tlib_vim/autoload/tlib/normal.vim')
-rwxr-xr-xvim/bundle/tlib_vim/autoload/tlib/normal.vim34
1 files changed, 34 insertions, 0 deletions
diff --git a/vim/bundle/tlib_vim/autoload/tlib/normal.vim b/vim/bundle/tlib_vim/autoload/tlib/normal.vim
new file mode 100755
index 0000000..faaa444
--- /dev/null
+++ b/vim/bundle/tlib_vim/autoload/tlib/normal.vim
@@ -0,0 +1,34 @@
+" normal.vim
+" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim])
+" @Website: http://www.vim.org/account/profile.php?user_id=4037
+" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
+" @Created: 2008-10-06.
+" @Last Change: 2010-09-22.
+" @Revision: 28
+
+let s:save_cpo = &cpo
+set cpo&vim
+
+
+" :display: tlib#normal#WithRegister(cmd, ?register='t', ?norm_cmd='norm!')
+" Execute a normal command while maintaining all registers.
+function! tlib#normal#WithRegister(cmd, ...) "{{{3
+ TVarArg ['register', 't'], ['norm_cmd', 'norm!']
+ let registers = {}
+ for reg in split('123456789'. register, '\zs')
+ exec 'let registers[reg] = @'. reg
+ endfor
+ exec 'let reg = @'. register
+ try
+ exec norm_cmd .' '. a:cmd
+ exec 'return @'. register
+ finally
+ for [reg, value] in items(registers)
+ exec 'let @'. reg .' = value'
+ endfor
+ endtry
+endf
+
+
+let &cpo = s:save_cpo
+unlet s:save_cpo