1

Vim documentation states how to run command and normal mode commands (source):

vim.command(str)                                        python-command
        Executes the vim (ex-mode) command str.  Returns None.
        Examples: 
            :py vim.command("set tw=72")
            :py vim.command("%s/aaa/bbb/g")

       The following definition executes Normal mode commands: 
                def normal(str):
                        vim.command("normal "+str)
                # Note the use of single quotes to delimit a string containing
                # double quotes
                normal('"a2dd"aP')

Is there a way to use visual modes using python/dyn?

When I select something and start writing a command, the command gets substituted with :'<,'>. I guess its some kind of selection identificator. Is it possible to explicitely state the selected region before a command?

For example, I want to select several lines or particular block and lower case it. In VIM visual block mode I could simply press u, but how could I run this command using python/dyn vim.command()?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.