Programmatically execute vim commands?
        Posted  
        
            by Ben Gartner
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Ben Gartner
        
        
        
        Published on 2010-06-13T17:39:01Z
        Indexed on 
            2010/06/13
            17:42 UTC
        
        
        Read the original article
        Hit count: 363
        
I'm interested in setting up a TDD environment for developing Vim scripts and rc files. As a simple example, say I want to have vim insert 8 spaces when I press the tab key. I would set up a script that did the following:
- Launch vim using a sandboxed .vimrc file
- press i
- press tab
- press esc
- press :w test_out
- assert that test_out contains ' '
by the default config in vim, this would fail. However, once I add set expandtab to my .vimrc file, the test will pass.
So the question is, how do I programmatically issue these commands? 'vim -c ' is close, but seems to only work for ex mode commands. Any suggestions? This question seem to be thoroughly google-proof.
© Stack Overflow or respective owner