Vim Tips Wiki
Advertisement

Put any tip related to the Clojure language

Here's one:


How to Comment / Uncomment in Clojure:

The comment string is the character ;

Here's a little script I put in my ~/.vimrc

function! ClojureCommentUncomment() "did you find the character ; at the beginning of the line?

 if getline(".") =~ '\;'
   let hls=@/  "take care of highlighting
   s/^\;//     "remove the ; at the beginning of the line
   let @/=hls
 else
   let hls=@/
   s/^/\;/ "add a ; at the beginning of the line
   let @/=hls
 endif

endfunction map ,. :call ClojureCommentUncomment()<CR>

Restart Vim and type ,. on any file (not just Clojure files) You could make this more restrictive by adding a filetype check.


Advertisement