Author Topic: vim-mode line joining - tab sometimes getting inserted  (Read 2254 times)

Ian P

  • Community Member
  • Posts: 59
  • Hero Points: 2
vim-mode line joining - tab sometimes getting inserted
« on: July 01, 2010, 10:16:32 pm »

When vi/vim joins two lines (vim command 'J') if there is any white-space at the join point it replaces it all with a single space, otherwise it inserts one space. I use SE 2009 in vim mode and generally it is doing that, but often I find spurious tab character in my code where lines have been joined.

After a bit of trial and error I've found that when I join two lines, if the join point is one character less than a tab stop position then it inserts a tab, otherwise it inserts a space. This is particularly annoying because it means the inserted tab takes up one space in the view so you can't see that its happened - it only shows up visually if other changes are made to the line so the tab's position changes.

For example, if I have it set for a tab size of 4 or 8 and edit these two blocks to join the first two lines in each case:

if (aa)

if (aaa)

The result is this:

if (aa)   {

if (aaa) {
Which may look the same (well it would in a fixed font anyway) but in the first case the character inserted before the { is a tab, not a space.

« Last Edit: July 01, 2010, 10:18:25 pm by Ian P »