Coder Social home page Coder Social logo

emacsmirror / whole-line-or-region Goto Github PK

View Code? Open in Web Editor NEW

This project forked from purcell/whole-line-or-region

0.0 2.0 0.0 57 KB

Operate on current line if region undefined

Home Page: https://github.com/purcell/whole-line-or-region

Emacs Lisp 96.55% Makefile 3.45%

whole-line-or-region's Introduction

Melpa Status Melpa Stable Status Build Status Support me

In Emacs, operate on the current line if no region is active

This minor mode allows functions to operate on the current line if they would normally operate on a region and region is currently undefined.

The primary use for this is to kill (cut) the current line if no region is defined, and kill-region is invoked. It basically saves you the effort of going to the begining of the line, selecting the text up to the end of the line, and killing. Similarly, when yanking, it's smart enough to know that the string to be yanked was killed as a whole line, and it should be yanked as one, too. So you don't need to position yourself at the start of the line before yanking. If region is defined, though, all functions act as normal.

This minor mode was originally written by Joe Casadonte in 2001, and was maintained for recent Emacsen by Steve Purcell for several years. In 2020 the internals were rewritten to use modern Emacs features such as filter-buffer-substring-function and yank-handler, and thereby behave more consistently.

Usage

Enabling whole-line-or-region-global-mode causes the common kill/copy commands to be remapped. When no region is active, if you type C-w then the current line will be copied. When yanked using C-y, it will be yanked before the current line. If a region is active, e.g. if you have selected a word, the commands will behave as usual.

Other commands are similarly overridden, e.g. comment-dwim: see whole-line-or-region-local-mode-map for more details.

Using positive numeric prefix arguments, you can operate on multiple lines at once, e.g. C-3 C-w will kill 3 whole lines, beginning with the current line. Cycling yanks with yank-pop (M-w) should also work correctly.

Functions are provided which allow you to easily wrap other commands so that they will also operate on the current line by default. The wrapped commands can then similarly be remapped in whole-line-or-region-local-mode-map.

Installation

Manual

Ensure whole-line-or-region.el is in a directory on your load-path, and add the following to your ~/.emacs or ~/.emacs.d/init.el:

(require 'whole-line-or-region)

MELPA

If you're an Emacs 24 user or you have a recent version of package.el you can install whole-line-or-region from the MELPA repository. The version of whole-line-or-region there will always be up-to-date.

About

Author: Steve Purcell

Homepage: https://github.com/purcell/whole-line-or-region


๐Ÿ’ Support this project and my other Open Source work

๐Ÿ’ผ LinkedIn profile

โœ sanityinc.com

๐Ÿฆ @sanityinc

whole-line-or-region's People

Contributors

andersjohansson avatar ivan-krukov avatar purcell avatar typas avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.