I want to create a binding so that pressing “Shift I I” writes python import statements.
I think it should be a map, like this:
:map <S-i><S-i> ...
I’m not sure how to map my desired output. I want to enter insert mode, then type:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
My issue is that I do not know how to insert the return character in this mapping. This mapping works, but only produces one line:
:map <S-i><S-i> iimport numpy as np
I tried using a return character,
:map <S-i><S-i> iimport numpy as npnimoprt pandas as pd
but that didn’t work. It just writes the return character out.
I also tried entering a space in the file,
imoprt pandas as pd:map <S-i><S-i> iimport numpy as np
imoprt pandas as pd
but that yields the error
Error detected while processing /Users/kilojoules/.vimrc:
line 22:
E492: Not an editor command: imoprt pandas as pd
How can I make this mapping write out the desired import statements?