From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jason Earl Newsgroups: gmane.emacs.help Subject: Re: Equivalent of vim's o or O commands Date: Tue, 05 Feb 2008 17:49:58 -0700 Organization: XMission http://www.xmission.com/ Message-ID: <8763x229jd.fsf@xmission.com> References: <3e30bd04-f387-4b8f-82bf-d088981089d1@s8g2000prg.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1202274667 7389 80.91.229.12 (6 Feb 2008 05:11:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 6 Feb 2008 05:11:07 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Feb 06 06:11:29 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 1JMcZF-0000EO-0b for geh-help-gnu-emacs@m.gmane.org; Wed, 06 Feb 2008 06:11:29 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JMcYm-00069v-Ku for geh-help-gnu-emacs@m.gmane.org; Wed, 06 Feb 2008 00:11:00 -0500 Original-Path: shelby.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!newscon04.news.prodigy.net!prodigy.net!newsfeed.telusplanet.net!newsfeed.telus.net!xmission!nnrp.xmission!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 53 Original-NNTP-Posting-Host: nat.visiongrp.com Original-X-Trace: news.xmission.com 1202258994 15066 65.162.166.20 (6 Feb 2008 00:49:54 GMT) Original-X-Complaints-To: abuse@xmission.com Original-NNTP-Posting-Date: Wed, 6 Feb 2008 00:49:54 +0000 (UTC) Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAAAAAByaaZbAAAACXBIWXMAABKbAAASmwHgklkM AAABz0lEQVRIx5VW2bHDIAz0jPtRS+pxG1E/fEUHhzjeC2EcJ8JZ0LFa80AkrrgB6L/0K0ypc3Y9 UqYh0I9eOtzG8hwPdkARJiJmOQBk20Ft0OuDcANA/78jdpd2AL99sFy4NDbQLVrsCbAEXYA3DVzE 8D/gkNbJpZsdhHMMN2kdAOKrSo8ttNZrTrYdnEgVweWu0p5b5vjrwSXxoSv73dIibaoSu/4u/vyB sxyD/9YCiE7IRrOP9M4uSK1OrcgOkANA2+PVBsHfQU8AbafRH8e0LoBUSDn2w+JiJiOXi6AngBx7 erYTF42M3wDYAFvH/erSGlNZg/7q0s9pLR1xLNyJGqo8xo2Qzm918AW0etoeQcMHldaDz43STnru k9Lo3XslGgeLidQ/Is0l3bJKkDQ71L7GZGY8DqlEF4l4oSQRMIBQT5JnadSSom8nmZEk/xxinLSR XcgoUyHhbQ8DZHZh1la298tKDaF5ZhXjjd6YALvczwB1SX4CWOGWGGRySQ79kGesmtNLUdOUFkDU gceCp9cuEj6ogYbgqHSzyYW59MKY9EUDqbrTyyGF6eiA2g+6gtoUZKr90A8jlXzL4STZTz3aoN3Q zkNx7unnn3YC+gA3WfRuzLleFgAAAEV6VFh0Q29tbWVudAAAeNpT8MxNTE9VSE/NSy1KLElNUUiq VHD3C1Vwz8gvLilOLsosKFHQSEkty0xOtS3Iyy1KLNfkAgDinBJPV21RsgAAABp6VFh0SlBFRy1D b2xvcnNwYWNlAAB42jMEAAAyADKxisffAAAAInpUWHRKUEVHLVNhbXBsaW5nLWZhY3RvcnMAAHja M6wwBAABtwDbWB23uwAAAABJRU5ErkJggg== User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) Cancel-Lock: sha1:r+wn1Al5tmbn0u3UsCjX6Fqqn0c= Original-Xref: shelby.stanford.edu gnu.emacs.help:155858 X-Mailman-Approved-At: Wed, 06 Feb 2008 00:10:10 -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:51237 Archived-At: Brian Adkins writes: > 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 One of the things that you might consider trying is viper-mode. That way you don't have to give up your typist friendly keystrokes just to use Emacs' lisp-scriptable goodness. Jason