From owner-freebsd-questions@FreeBSD.ORG Mon Jun 15 01:18:23 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C2AE5106566C for ; Mon, 15 Jun 2009 01:18:23 +0000 (UTC) (envelope-from vogelke@hcst.com) Received: from beta.hcst.com (beta.hcst.com [192.52.183.241]) by mx1.freebsd.org (Postfix) with ESMTP id 83EF48FC12 for ; Mon, 15 Jun 2009 01:18:23 +0000 (UTC) (envelope-from vogelke@hcst.com) Received: from beta.hcst.com (localhost [127.0.0.1]) by beta.hcst.com (8.13.8/8.13.8/Debian-3) with ESMTP id n5F1IHax014656 for ; Sun, 14 Jun 2009 21:18:18 -0400 Received: (from vogelke@localhost) by beta.hcst.com (8.13.8/8.13.8/Submit) id n5F1IHd5014655; Sun, 14 Jun 2009 21:18:17 -0400 Received: by kev.msw.wpafb.af.mil (Postfix, from userid 32768) id 1C435BEE2; Sun, 14 Jun 2009 21:18:05 -0400 (EDT) To: freebsd-questions@freebsd.org In-reply-to: (message from Daniel Underwood on Sat, 13 Jun 2009 20:18:02 -0400) Organization: Oasis Systems Inc. X-Disclaimer: I don't speak for the USAF or Oasis. X-GPG-ID: 1024D/711752A0 2006-06-27 Karl Vogel X-GPG-Fingerprint: 56EB 6DBF 4224 C953 F417 CC99 4C7C 7D46 7117 52A0 Message-Id: <20090615011806.1C435BEE2@kev.msw.wpafb.af.mil> Date: Sun, 14 Jun 2009 21:18:05 -0400 (EDT) From: vogelke+unix@pobox.com (Karl Vogel) Subject: Re: Terminal / vim / shortcuts X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: vogelke+unix@pobox.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Jun 2009 01:18:24 -0000 >> On Sat, 13 Jun 2009 20:18:02 -0400, >> Daniel Underwood said: D> I edit python code in vim using Terminal on xfce. I find myself, not D> surprisingly, having to exit "insert mode" and save changes frequently D> (when making code changes and wishing to test the immediate effects of D> the changes in a separate terminal). This requires pressing 4 keys: D> "esc", ":", "w", and "enter". How can I configure a shortcut (ideally D> using an F# key) that will perform this sequence of 4 key-presses? If you're moving to a separate terminal to test, that sounds like another keystroke or mouse-movement. You could set up vi/vim to autosave on suspension, then use one function key to suspend back to your shell prompt, run your test, and use a shell alias to get back to your edit session. VIM settings: set autowrite imap #5 :suspend Shell aliases (works for bash/zsh, syntax for tcsh is different): alias 1='%1' alias 2='%2' alias 3='%3' alias 4='%4' alias 5='%5' alias 6='%6' alias 7='%7' alias 8='%8' alias 9='%9' This way, you can restart a suspended job without having to type a dopey percent sign first. Here are some other VIM mappings I've found useful. I hate using the shift key unless it's essential, so to indent/deindent: map ; >> map = << It's easier for me to see context when the cursor is around the middle of the screen: map q z. Sometimes I like a column ruler just for a second or two. Press 'E' to see it, then 'u': map E oi....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+ I like my paragraphs ragged-right, around 75 columns long. This lets me reformat whatever paragraph I'm in by pressing 'v': map v }jmbk{ma}:'a,.!fmt -1^V|fmt -75'b The "^V" is an actual control character, so you have to hit Ctrl-V twice to put it in your .vimrc file. My .vimrc file is here: http://www.hcst.net/~vogelke/src/editors/vim/ -- Karl Vogel I don't speak for the USAF or my company To sin by silence when they should protest makes cowards of men. --Abraham Lincoln