See: * [vim the hard way](https://learnvimscriptthehardway.stevelosh.com/chapters/23.html) ## Defining functions ```vim function CommentLine() :s@.*@@ endfunction function UnCommentLine() :s@@\1@ endfunction ``` ## Calling functions ```vim call CommentLine() ``` ## Mapping Functions ```vim nnoremap \kc :call CommentLine() vnoremap \kc :call CommentLine() ```