End of a user function started with :function
Example
Normal 0 / 2Command-line 1 / 2Normal 2 / 2End of a user function started with :function.
Script runtime
- Load state
not sourced
Command entered · ready to apply
Script runtime
- Load state
not sourced
Command line
- Typed text
:source legacy-twice.vim- Insertion offset
24
:endfunction appears in the complete source file. The legacy function/endfunction block uses a:n; Twice(3) returns 6.
Script runtime
- Defined function
Twice(n)- echo output
6
Before & after
Before
Script runtime
- Load state
not sourced
After
Script runtime
- Defined function
Twice(n)- echo output
6
Documentation-backed illustration. Vim has +eval and supports the displayed script syntax; source code is prepared as legacy-twice.vim. :endfunction appears in the complete source file. The legacy function/endfunction block uses a:n; Twice(3) returns 6. Primary help: :endfunction.
function! Twice(n) abort
return a:n * 2
endfunction
echo Twice(3)Cursor on line 1, column 1Details & Vim help
End of a user function started with :function. This Ex reference uses the full command name; the alphabetical index omits arguments. Supply the ranges, arguments, flags and prerequisite state documented in the linked help. Press Enter to submit a complete command. The index spelling :endf[unction] puts the optional abbreviation suffix in square brackets; those brackets are not typed. Availability and exact behavior can depend on Vim build features, options, mappings and editor state; the linked help is authoritative.