sponsor Vim development Vim logo Vim Book Ad

basic Tip #532: usefule keymaps -- for comment out,etc..

 tip karma   Rating 2/16, Viewed by 1593 

Read and edit this tip on the Vim tip wiki. The wiki may have a more recent version of this tip.

created:   August 18, 2003 4:21      complexity:   basic
author:   rajesh      as of Vim:   5.7

-->a key map for commenting out lines -- use f12 key
append this line into your .vimrc/.gvim rc file
map <F12> ^i#<Esc>j
-->key maps to avoid a long shift press
nmap  :X        :x
nmap  :W        :w
nmap  :Q        :q

 rate this tip  Life Changing Helpful Unfulfilling 

<< 1-2-3, let's make gvim.exe for free | Page 1 of 123 in header of :hardcopy >>

Additional Notes

yeti@physics.muni.cz, August 18, 2003 12:40
Remapping :something in normal mode is quite silly.

command -nargs=0 -bang Q q<bang>

is probably a better method of dealing with the too long shift problem.
ewan.chalmers@comnitel.com, August 19, 2003 8:06
Key maps for Java style comment/uncomment

"comment out with CTRL-/
map ^_ 0i//<esc>j

"uncomment with CTRL-\
map ^\ :s/\/\///<CR>j
shawvrana at acm dot org, August 19, 2003 9:22
Or if you like C-style comments:

" Comment current line with ctrl-k in command mode
map <c-k> mzI/* <esc>A */ <esc>`z

" uncomment line line with ctrl-l
map <c-l> <esc>:s/\(.*\)\(\/\* \)\(.*\)\(\*\/\)/\1\3/<CR>
Luc Hermitte -- hermitte {at} free.fr, August 19, 2003 13:39
Have you considered the numerous plugins that are dedicated to commenting and uncommenting texts whatever the language is ?

I'm using EnhancedCommentify and it is working just fine!
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
Sponsored by Web Concept Group Inc. SourceForge.net Logo