l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
October 20: Web Application Hacking: How to Make and Break Security on the Web
Next Installfest:
TBD
Latest News:
Oct. 10: LUGOD Installfests coming again soon
Page last updated:
2004 Apr 02 11:04

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] serendipity with vim
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] serendipity with vim



these are the macros i use most.

this is VERY useful when you're editing email.  a truly wonderful macro
that reformats paragraphs to linewidth.  i use it all the time.  just
press the "home" key to reformat a paragraph.

   " Formats a paragraph (using home key).  Sets width textwidth.
   map <kHome> gq}
   map <Home>  gq}


this next macro may be my favorite.  rather than running a spell checker
on a whole email, checks a single word for spelling.  much faster.  or
if someone uses a word i don't know, just place the cursor over the word
and press delete.  you have to apt-get dict, of course.

   " This is my favorite mapping!
   " <del> in insert/cmd mode runs dict on word which the cursor is on.
   map  <del> :!dict <cword><CR>


this one is neat.  when i program on a console, i like to stick with 80
characters per line.  when i'm using X, i sometimes relax that.  when i
want to use 80 cols/line when i program in X, i override this with a
modeline:

   " If I'm programming in an xterm, unset textwidth.  If I'm in a console,
   " use 80 columns per line, otherwise things get unreadable. 
   if $TERM == "xterm"
      au BufNewFile,BufRead *.f90,*.for,*.c,*.cc,*.html,*.pl,*.tex set tw=0 wm=0
   endif


i use the "q" recording facility all the time, but i also hit "q" often
enough to push it out of the way so i don't hit it by accident:

   " Make Q start recording instead of q.  I always hit q in cmd mode.
   noremap q <Nop>
   noremap Q q


and multi-session yanks are always cool:

   " _Y: Yank the highlighted block of text (or a single line) to a tmp file.
   " _P: Put the text yanked with \_Y (possibly in another invocation of Vim).
   nmap _Y :.w! ~/.vim_yank_tmp<CR>
   vmap _Y :w! ~/.vim_yank_tmp<CR>
   nmap _P :r ~/.vim_yank_tmp<CR>


lastly, this is cool.  say you're programming some C code and you forgot
how a function is prototyped.  or perhaps you just added a function to a
.c file and you want to add a prototype quickly to the .h file.  or say
you just started writing a .c file, and you want to create the .h file.
all you got to do is type "header" in colon mode:

   cmap header sp %:r.h


pete

ps- i love seeing people's vim tips.  it's cool seeing what people find
useful.

-- 
Make everything as simple as possible, but no simpler.  -- Albert Einstein
GPG Instructions: http://www.dirac.org/linux/gpg
GPG Fingerprint: B9F1 6CF3 47C4 7CD8 D33E 70A9 A3B9 1945 67EA 951D
_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
Sunset Systems
Who graciously hosts our website & mailing lists!