diff --git a/tools/input_editing/vim/vim.xsl b/tools/input_editing/vim/vim.xsl
index 6024c76d28..d5800b3ec6 100644
--- a/tools/input_editing/vim/vim.xsl
+++ b/tools/input_editing/vim/vim.xsl
@@ -75,6 +75,7 @@ syn keyword cp2kConstant
syn keyword cp2kSection
syn keyword cp2kSection END
+syn keyword cp2kSection ENDIF
syn match cp2kBegSection '^\s*&\w\+' contains=cp2kSection
syn match cp2kEndSection '^\s*&END\s*\w\+' contains=cp2kSection
@@ -92,7 +93,7 @@ syn keyword cp2kKeyword
" CP2K preprocessing directives
"-----------------------------------------------------------------/
-syn keyword cp2kPreProc endif if include set
+syn keyword cp2kPreProc endif if include set xctype
"-----------------------------------------------------------------/
" CP2K strings
@@ -119,7 +120,7 @@ endif
let b:did_indent = 1
setlocal indentexpr=GetCp2kIndent()
-setlocal indentkeys+=0=~&END,0=#,0=@
+setlocal indentkeys+=0=~&END,0=~@ENDIF,0=#,0=@
setlocal nosmartindent
if exists("*GetCp2kIndent")
@@ -133,23 +134,15 @@ function! GetCp2kIndent()
endif
let ind = indent(lnum)
let line = getline(lnum)
- if line =~ '^\s*&'
+ if line =~ '^\s*\c\%(&\|@IF\)'
let ind += &shiftwidth
- if line =~ '^\s*\c\%(&END\)\>'
+ if line =~ '^\s*\c\%(&END\|@ENDIF\)\>'
let ind -= &shiftwidth
endif
- elseif line =~ '^\s*\c\%(@if\|@endif\|@include\|@set\)\>'
- let plnum = lnum
- while getline(plnum) =~ '^\s*@'
- let plnum -= 1
- endwhile
- let ind = indent(plnum)
endif
let line = getline(v:lnum)
- if line =~ '^\s*\c\%(&END\)\>'
+ if line =~ '^\s*\c\%(&END\|@ENDIF\)\>'
let ind -= &shiftwidth
- elseif line =~ '^\s*@'
- let ind = 0
endif
return ind
endfunction