Skip to content Skip to sidebar Skip to footer

Python, VIM: How Do I Count The Lines In A VIM Register?

The Python, VIM bindings give me ways of manipulating: windows, buffers and ranges but absolutely no way of messing with registers. vim.command('let @'.='%s'' % vim.current.buffer[

Solution 1:

In python you can get the value of a vim register by vim.eval("@a") for example.

If you want to count the lines (\n) in a register you can do it either in vim or python.

E.g. in vim:

len(split(@a, '\n'))

in python

#var is the variable containing @a in vim
len(re.split("\n",var))

Post a Comment for "Python, VIM: How Do I Count The Lines In A VIM Register?"