How to comment in vim while respecting the indent?
vim
Solution
Try using the `^` command instead of `0`. Or, use the `I` command to insert before the first nonspace character on the line.
Problem
I'm trying to make a mapping in vim to insert comments (for example, "# " - box with a space) while respecting the indenting. So, instead of commenting like this: ``` class MyFrame(wx.Frame): def __init__(self, title, pos, size): # wx.Frame.__init__(self, None, -1, title, pos, size) # menuFile = wx.Menu() ``` I'd to insert the "# " in the code like this, ``` class MyFrame(wx.Frame): def __init__(self, title, pos, size): # wx.Frame.__init__(self, None, -1, title, pos, size) # menuFile = wx.Menu() ``` therefore respecting the indent (which can be tabs or space). I was trying to get it to work with vim's 0 (zero) command which gets you to the first character in the line, but have been unable. Please, help. I'd be grateful for all ideas and practical suggestions.