(Adjust previous/next navigation + minor manual clean)
Line 2:
Line 2:
{{TipImported
{{TipImported
|id=522
|id=522
−
|previous=520
+
|previous=519
|next=523
|next=523
−
|created=July 31, 2003
+
|created=2003
|complexity=basic
|complexity=basic
|author=Breadman
|author=Breadman
Line 13:
Line 13:
}}
}}
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:
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:
−
<pre>
<pre>
"Fixes a rare autoindent error
"Fixes a rare autoindent error
Latest revision as of 02:26, March 30, 2010
Please review this tip:
This tip was imported from vim.org and needs general review.
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>"
else
return "\<CR>"
endif
endf