On keystroke insert line of code in (mac)vim, for pdb
Question: I'm looking for the way to insert a line of code with a keystroke like
`leader``p` in Macvim

I want to insert the following line of code:

    
    
    import pdb; pdb.set_trace()
    

Probably not an unheard of line of code in python land


Answer: I'd use a simple mapping (without functions) to leader p:

    
    
    nnoremap <leader>p oimport pdb; pdb.set_trace()<Esc>
    

When pressing o, this enters insert mode inserts a blank line after the
current one (with `o`) and then types `import pdb; pdb.set_trace()`, finally
it goes back to normal mode (with `Esq`).

* * *

If you want to insert the code before the current line replace o by O:

    
    
    nnoremap <leader>p Oimport pdb; pdb.set_trace()<Esc>
    

Or alternatively you could set this for leader shift-p:

    
    
    nnoremap <leader><S-p> Oimport pdb; pdb.set_trace()<Esc>
    

