Code Monkey home page Code Monkey logo

readline.vim's Introduction

readline.vim

Readline is a library used for implementing line editing across many command-line tools (including Bash and other shells and interpreters). Readline ships with a default set of key-bindings that you are probably already familiar with. The Readline default bindings is a mixture of traditional Unix and Emacs bindings.

This plugins implements a subset of Readline's default keyboard commands to Vim's command-line mode. Mappings available include deletion and navigation by words and other useful stuff.

Features

What makes this plugin different from similar plugins is that it implements a larger subset of the Readline mappings, and that it does a better job of mimicking the Readline behavior for each command.

The word movement and deletion commands have different behavior between Vim and Readline. The biggest difference is that in Readline punctuation is always skipped when searching for a word boundary. Another difference is that _ (underscore) is treated as a word delimiter. This plugin implements the Readline behavior for word movement and deletion commands.

Examples

Following are a few examples illustrating when this plugin can be useful. In each example _ is used to indicate the current cursor position.

#1

Deleting last two elements of path argument to :cd.

Command line Command
:cd path/to/dir/_ M-Backspace
:cd path/to/_ M-Backspace
:cd path/_

#2

Deleting path argument to :edit completely.

Command line Command
:edit path/to/file_ C-w
:edit _

#3

Adding ! to :edit command.

Command line Command
:edit path/to/file_ C-a
:_edit path/to/file M-f
:edit_ path/to/file !
:edit!_ path/to/file

More documentation

See the documentation for documentation of all mappings implemented by this plugin.

readline.vim's People

Contributors

mmadrid avatar ryvnf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

readline.vim's Issues

Is it possible to have readline.vim overrides vim-rsi?

I like the readline mappings in insert mode as vim-rsi provides, but I also like that readline.vim in commandline mode is more "readline-like".

However when I have both installed, vim-rsi takes precedence. As vim-rsi doesn't provide an option to disable it in commandline mode, is it possible to somehow force readline.vim to override vim-rsis mappings or prevent vim-rsi form overriding readline.vims mappings?

No `delete_longword()`

I miss a counterpart for rubout_longword() to delete forward to end of space delimited word 😄

P.S. It would be great to update the documentation using established Vim terms:

  • a space delimited word (a.k.a long word) is WORD.
  • a regular word that is delimited by iskeyword is word (:h word vs :h WORD).

Control W <c-w> twice doesn't save into s:yankbuf

Hello there!

Thank you so much for this plugin, moving around the vim command line was really challenging until I found your work!

I found a minor inconsistency with the behavior of s:yankbuf on the vim command-line compared to the bash command-line when using <c-w> twice.

For example:

in bash

echo hello world█ # <c-w>
echo hello █ # <c-w>
echo █ # <c-y>
echo hello world█

in vim

:echo hello world█ # <c-w>
:echo hello █ # <c-w>
:echo █ # <c-y>
:echo hello █

<Esc> is mapped to <Nop>

Escape is currently mapped to do nothing in the plugin This is to prevent an invalid meta-mapping from closing the command line. A user on IRC has requested that should not be remapped.

I personally think that pressing an invalid meta-mapping (like M-v when user meant to press M-b) closing or running the command-line can be very frustrating, which is the motivation for mapping it to <Nop>. I also think that people generally press ENTER to run the command, or CTRL-C to cancel it (but that is only from my experience, and might be wrong).

I mainly see two possible solutions for this:

  1. Adding an option (like g:readline_esc_nop) which allows the user to explicitly get the behavior they want.

  2. Creating a mapping for <Esc><Esc> which emulates the single <Esc> press. This would require reading the x-flag in 'cpoptions', and would require checking if a custom mapping should be run when pressing this key combination.

  3. Not mapping ESC and encouraging user to map <Esc> to <Nop> in their vimrc if this is a problem.

Of these two solution, I think number 1 is to be preferred, as it is simple. I personally don't like number 3, as I like the current behavior (but I would be open to implement it if enough other people would prefer it).

I also don't know how many other people dislike remapping ESC, so this might not be a problem. But I assume the user on IRC can't be the only one.

using readline.vim

I followed the instructions at https://www.vim.org/scripts/script.php?script_id=5633
and unzipped the directory into my .vim. I got plugin/readline.vim in my .vim and doc/readline.txt

But I am unable to figure out how to use this here. How do I "load" the file in my .vimrc (or something else) and start using it? I could not figure out the instructions. Any suggestions?

Implement C-@and C-x C-x mark mappings

It is possible to implement the C-@ (set mark) and C-x C-x (exchange point and mark) commands from Readline.

Problems with implementing these mappings it is difficult to ensure the mark is in sync when the user changes to another line in history. Readline will reset the mark to column 0 each time the user changes to another line in history, this is difficult to achieve from Vim.

Also don't think these mappings are widely used, so it might not be the best idea to implement these in readline.vim, if the intention is to keep the plugin small and simple.

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.