Tip 522 Printable Monobook Previous Next

created 2003 · complexity basic · author Breadman · version 5.7

When splitting a line in two, I sometimes insert a return before a space. Unfortunately, this mangles the autoindentation: the last tab turns into spaces. The following map fixes that problem:

"Fixes a rare autoindent error
inoremap <CR> <C-R>=ReturnWrapper()<CR>
function ReturnWrapper()
  if strpart(getline('.'), col('.') - 1) =~ '^\s*\S'
    return "\<Esc>wi\<CR>"
    return "\<CR>"


Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.