From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Brian Adkins Newsgroups: gmane.emacs.help Subject: Re: Equivalent of vim's o or O commands Date: Tue, 5 Feb 2008 11:47:58 -0800 (PST) Organization: http://groups.google.com Message-ID: <3e30bd04-f387-4b8f-82bf-d088981089d1@s8g2000prg.googlegroups.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1202248716 8303 80.91.229.12 (5 Feb 2008 21:58:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 5 Feb 2008 21:58:36 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Feb 05 22:58:57 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JMVoe-0008FM-BK for geh-help-gnu-emacs@m.gmane.org; Tue, 05 Feb 2008 22:58:56 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JMVoC-0002gm-6r for geh-help-gnu-emacs@m.gmane.org; Tue, 05 Feb 2008 16:58:28 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!s8g2000prg.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 45 Original-NNTP-Posting-Host: 68.209.204.112 Original-X-Trace: posting.google.com 1202240879 10081 127.0.0.1 (5 Feb 2008 19:47:59 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Tue, 5 Feb 2008 19:47:59 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: s8g2000prg.googlegroups.com; posting-host=68.209.204.112; posting-account=Uust-woAAAAfaTc8iUxK0_NIe578kqTZ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.11) Gecko/20071204 Ubuntu/7.10 (gutsy) Firefox/2.0.0.11, gzip(gfe), gzip(gfe) Original-Xref: shelby.stanford.edu gnu.emacs.help:155854 X-Mailman-Approved-At: Tue, 05 Feb 2008 16:57:20 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:51232 Archived-At: On Feb 5, 2:22 pm, Brian Adkins wrote: > I would like to have the equivalent of vim's o or O commands in emacs. > The o command will open a new line below the cursor and position the > cursor properly indented (if autoindent is on). The O command does the > same but opens the line above the cursor. > > In emacs, C-o will open a line above the cursor if the cursor is at > the beginning of the line (but won't properly indent), but splits the > line if the cursor is within some text. > > This is such a common operation for me, that I would like to bind it > to a simple combination instead of requiring C-e C-j. > > I failed to find a good "emacs for vim users" reference on Google. > There are some partial ones that are helpful, but I would like a more > complete reference as I consider transitioning from vim to emacs. If > anyone knows of one, I'd appreciate a link. > > Thanks, > Brian Adkins I should have searched the group archives first. I found a satisfactory solution from a 2002 posting :) (defun bja-open-line-below () (interactive) (end-of-line) (open-line 1) (next-line 1) (indent-according-to-mode)) (defun bja-open-line-above () (interactive) (beginning-of-line) (open-line 1) (indent-according-to-mode)) (global-set-key [?\C-o] 'bja-open-line-below) (global-set-key [?\M-o] 'bja-open-line-above) Being able to customize emacs with elisp is one of the main reasons I'm considering a switch (that and being able to use emacs/slime for Lisp programming). Brian