(Assign tip id + convert to TipNew template) |
(Change <tt> to <code>, perhaps also minor tweak.) |
||
Line 3: | Line 3: | ||
|previous=1630 |
|previous=1630 |
||
|next=1632 |
|next=1632 |
||
− | |created= |
+ | |created=2009 |
|complexity=basic |
|complexity=basic |
||
|author= |
|author= |
||
Line 14: | Line 14: | ||
==Commenting and uncommenting== |
==Commenting and uncommenting== |
||
− | The comment leader for Clojure is the < |
+ | The comment leader for Clojure is the <code>;</code> character. This snippet allows easy commenting and uncommenting of lines. |
<pre> |
<pre> |
||
map <Leader>. :call ClojureCommentUncomment()<CR> |
map <Leader>. :call ClojureCommentUncomment()<CR> |
||
Line 28: | Line 28: | ||
</pre> |
</pre> |
||
− | Typing < |
+ | Typing <code>\.</code> (assuming the default backslash leader) will remove <code>;</code> from the beginning of the current line if it is present (uncomment), or will insert it otherwise (comment). You could make this more restrictive by only adding the mapping for files of the Clojure filetype, or by adding it to <code>~/.vim/after/ftplugin/clojure.vim</code>. |
==References== |
==References== |
||
Line 37: | Line 37: | ||
{{todo}} |
{{todo}} |
||
*May need some information similar to [[VimTip1565]] for making Clojure a known filetype. |
*May need some information similar to [[VimTip1565]] for making Clojure a known filetype. |
||
− | *The tip used < |
+ | *The tip used <code>'\;'</code> but the backslash is redundant (I removed it). |
− | *The tip had < |
+ | *The tip had <code>if getline('.') =~ '\;'</code> but <code>s/^;//</code>. The former matches <code>;</code> anywhere in the line, while the latter only matches at the left margin. I changed it. |
Please fix it if my changes broke anything. [[User:JohnBeckett|JohnBeckett]] 10:25, September 5, 2009 (UTC) |
Please fix it if my changes broke anything. [[User:JohnBeckett|JohnBeckett]] 10:25, September 5, 2009 (UTC) |
Latest revision as of 06:41, 13 July 2012
Tips relating to the Clojure language will be given here.
Commenting and uncommenting[]
The comment leader for Clojure is the ;
character. This snippet allows easy commenting and uncommenting of lines.
map <Leader>. :call ClojureCommentUncomment()<CR> function! ClojureCommentUncomment() let search_saved = @/ if getline('.') =~ '^;' s/^;// " remove ';' at beginning of line else s/^/;/ " insert ';' at beginning of line endif let @/ = search_saved endfunction
Typing \.
(assuming the default backslash leader) will remove ;
from the beginning of the current line if it is present (uncomment), or will insert it otherwise (comment). You could make this more restrictive by only adding the mapping for files of the Clojure filetype, or by adding it to ~/.vim/after/ftplugin/clojure.vim
.
References[]
Comments[]
TO DO
- May need some information similar to VimTip1565 for making Clojure a known filetype.
- The tip used
'\;'
but the backslash is redundant (I removed it). - The tip had
if getline('.') =~ '\;'
buts/^;//
. The former matches;
anywhere in the line, while the latter only matches at the left margin. I changed it.
Please fix it if my changes broke anything. JohnBeckett 10:25, September 5, 2009 (UTC)