ryvnf / readline.vim

Readline emulation for command-line mode
88 stars 2 forks source link

using readline.vim #10

Closed maitra closed 11 months ago

maitra commented 11 months ago

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?

ryvnf commented 11 months ago

The files are in the correct places. Can you check the compatible option using set compatible??. Like most plugins, it will not load if compatible is enabled.

If it is enabled, you need to add set nocompatible at the top of your .vimrc.

maitra commented 11 months ago

Thank you. Here is my .vimrc I do not have set compatible set, but explicitly setting it to set nocompatible appears to not make a difference.

set runtimepath+=~/.vim

set termguicolors

colorscheme NeoSolarized

" Default value is "normal", Setting this option to "high" or "low" does use the
" same Solarized palette but simply shifts some values up or down in order to
" expand or compress the tonal range displayed.
let g:neosolarized_contrast = "normal"

" Special characters such as trailing whitespace, tabs, newlines, when displayed
" using ":set list" can be set to one of three levels depending on your needs.
" Default value is "normal". Provide "high" and "low" options.
let g:neosolarized_visibility = "normal"

" I make vertSplitBar a transparent background color. If you like the origin
" solarized vertSplitBar style more, set this value to 0.
let g:neosolarized_vertSplitBgTrans = 1

" If you wish to enable/disable NeoSolarized from displaying bold, underlined
" or italicized" typefaces, simply assign 1 or 0 to the appropriate variable.
" Default values:
let g:neosolarized_bold = 1
let g:neosolarized_underline = 1
let g:neosolarized_italic = 0

" Used to enable/disable "bold as bright" in Neovim terminal. If colors of bold
" text output by commands like `ls` aren't what you expect, you might want to
" try disabling this option. Default value:
let g:neosolarized_termBoldAsBright = 1

let g:python3_host_prog='/bin/python3'

set guicursor=i:block

let g:clipboard = {
  \   'name': 'xclip-clipman',
  \   'copy': {
  \   'name': 'xclip-clipman',
  \   'copy': {
  \      '+': 'xclip -selection clipboard',
  \      '*': 'xclip -selection clipboard',
  \    },
  \   'paste': {
  \      '+': 'xclip -selection clipboard -o',
  \      '*': 'xclip -selection clipboard -o',
  \   },
  \   'cache_enabled': 1,
  \ }

set clipboard=unnamedplus

Not sure what the issue is, yet.

ryvnf commented 11 months ago

I see. Are you running Vim with the GUI (gvim)?

The Alt/Meta keybindings are disabled work there by default. This is because it causes problems with inserting accented characters like åäö on some keyboard layouts. You can test other bindings like Ctrl-K to see if those works. Alternatively running Vim in a terminal. For gvim you need to explicitly enable the Meta bindings using let readline_meta = 1 in your .vimrc.

Can you also check if the plugin is loaded by running :let loaded readline after starting Vim? If it says the variable is undefined the plugin has not been loaded.

maitra commented 11 months ago

I see. Are you running Vim with the GUI (gvim)?

The Alt/Meta keybindings are disabled work there by default. This is because it causes problems with inserting accented characters like åäö on some keyboard layouts. You can test other bindings like Ctrl-K to see if those works. Alternatively running Vim in a terminal. For gvim you need to explicitly enable the Meta bindings using let readline_meta = 1 in your .vimrc.

Thanks! No, I do not have gvim installed. I also do have nvim installed, but this is about vim. Also, even Ctrl-f does not work, I only get "^F" in insert mode.

Can you also check if the plugin is loaded by running :let loaded readline after starting Vim? If it says the variable is undefined the plugin has not been loaded.

Right, I get:

E121: Undefined variable: loaded

However, it appears that the variable loaded is itself undefined. Thank you very much again for all your help!

ryvnf commented 11 months ago

Oh sorry. I meant :let loaded_readline with an underscore.

But it looks like you are expecting the keybindings to work in insert mode. This plugin only implements the Readline bindings for command-line mode (when you are typing : commands). This is by design since I think implementing the keybindings in insert mode overrides a lot of useful built-in mappings.

Mappings for insert mode would also have to be implemented differently from command-line mode which would increase the complexity of the plugin a lot when I prefer to keep it relatively small and simple.

maitra commented 11 months ago

Oh sorry. I meant :let loaded_readline with an underscore.

I see, I get: loaded_readline #1

But it looks like you are expecting the keybindings to work in insert mode. This plugin only implements the Readline bindings for command-line mode (when you are typing : commands). This is by design since I think implementing the keybindings in insert mode overrides a lot of useful built-in mappings.

OK, I see. I was hoping to get readline support while editing. Perhaps that is not possible here.

Mappings for insert mode would also have to be implemented differently from command-line mode which would increase the complexity of the plugin a lot when I prefer to keep it relatively small and simple.

I see, I will see if I can find a thorough implementation of readline also in insert mode. If you have suggestions, do let me know. Once again, thank you for all your help!

ryvnf commented 11 months ago

Tpope's rsi.vim implements Readline-like bindings in both insert and command-line mode. Its mappings are a bit different from readline.vim plugin since it uses builtin Vim commands which treats words a bit differently. I created this plugin because I wanted commands like Ctrl-W, Alt-B/F etc to work exactly like they do in Readline.

Someone asked previously in #6 if they could use rsi.vim with this plugin so they get readline.vim bindings for command-line mode but rsi.vim bindings in insert-mode. I am not sure if they managed to get that to work. If you do not care about the bindings not working exactly like in Readline you could also use rsi.vim by itself.

I do not know of any plugin which faithfully implements Readline's binding like this one in both insert and command-line mode.

ryvnf commented 11 months ago

Also thanks for being interested in trying out my plugin!

maitra commented 11 months ago

Thanks for your detailed answer. I was able to install rsl.vim and get it to work. Thanks also for all your help!