Skip to content

8ooo8/vim-easy-inline-motion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vim-easy-inline-motion

The snapshot of the highlight

Have you ever thought of utilizing the cursor motion command like 7w and 8b? Not easy to do so because hard to immediately judge how far the target word is away from our cursor? This plugin highlights the word tips with different colors so that users may immediately know the exact w or b command to instantly reach their target words.

Table of content

  1. Quick start
  2. Comparison with vim-easymotion
  3. Installation
  4. Configuration
  5. Commands

Quick start

In general, this plugin works well with the default configuration.

Highlight colors

A picture of the deault highlight colros

In the default configuration, a red color to mean one word forward/backward from your cursor position, pink to mean 2 words forward/backward from your cursor position, etc. The first 5 colors are red, pink, yellow, green and blue, and the second 5 colors are likely to be the dull version of the first 5 colors.

The colors is configurable, see color configuration. Please note that the colors differ on different running environment and therefore, the default colors shown on your vim may be different from the above picture.

Highlight rules

  1. This plugin highlights characters that built-in cursor motion command, w and b, may jump to.
  2. In the case that the word tips supposed to be highlighted are out of the current line, they are not highlighted. For instance, the cursor is at the end of a line, the next word tips are not highlighted since they are out of the current line.
  3. It can be configured to preview the highlighting of the adjacent lines -- preview the highlighting as if the cursor is moved to the adjacent lines using j or k or <up> or <down>. See g:easy_inline_motion_preview_lines for its configuration.
  4. The highlighting is off when it is in the insert mode.
  5. The highlighting can be turned on/off and toggled using commands or mapped keys.
  6. It can be configured to shade the lines getting highlighted (shade: turn other characters grey so that the reading of the highlight colors becomes easier). See configuration, commands and mapped keys for more information.

Comparison with vim-easymotion

vim-easy-inline-motion vim-easy-motion Comparison
Highlight with colors Make use of characters to declare the users' target words Reading colors consumes less time than reading characters
Auto highlighting Type the mapped keys to use its features Auto highlighting saves time on typing the mapped keys
Coverage: current and adjacent lines Coverage: whole buffer vim-easy-inline-motion lacks an ability to instantly reach faraway targets
Not direct support to an instant jump to non-word-tip characters Direct support to an instant jump to non-word-tip characters vim-easy-inline-motion lacks a direct support to an instant jump to non-word-tip characters

Please note that to keep an easy reading of vim-easymotion's highlights, this plugin hides its highlights when vim-easymotion's functions are triggered.

Installation

For example, with plugin manager, vim-plug:

Plug '8ooo8/vim-inline-easy-motion'

Configuration

Map a key to toggle the auto highlighting

map <Leader>eim <Plug>(easy-inline-motion-toggle-auto-highlight-mode)

Map a key to toggle the shading

map <Leader>sh <Plug>(easy-inline-motion-toggle-shading-mode)

The highlight colors

The g:easy_inline_motion_cterm_colors option

  1. What are cterm and gui in the sense of highlighting?
  2. cterm color cheat sheet

Assign an array of colors to this global variable to configure the highlight colors on the colored terminals.

"" 1st ID, i.e. 9, to highlight the tip of the previous and the next words,
"" 2nd ID, i.e.13, for the tip of the previous previous and the next next words, etc.
"" Please note that this plugin highlights more word tips as you assign more colors here.
let g:easy_inline_motion_cterm_colors = [9, 13, 11, 10, 27, 1, 5, 3, 28, 36]

The g:easy_inline_motion_gui_colors option

  1. What are cterm and gui in the sense of highlighting?

Assign an array of colors to this global variable to configure the highlight colors on the gui vim.

"" 1st color, i.e. '#ff0000', to highlight the tip of the previous and the next words,
"" 2nd color, i.e. '#ff00ff', for the tip of the previous previous and the next next words, etc.
"" Please note that this plugin highlights more word tips as you assign more colors here.
let g:easy_inline_motion_gui_colors = ['#ff0000', '#ff00ff', '#ffff00', '#00ff00', '#005fff',
  \ '#800000', '#800080', '#808000', '#00af00', '#00af87']

The shading color

The g:easy_inline_motion_shading_on option

"" 0 value to off, other values to on
let g:easy_inline_motion_shading_on = 1

The g:easy_inline_motion_shading_cterm_colors option

  1. What are cterm and gui in the sense of highlighting?
  2. cterm color cheat sheet
let g:easy_inline_motion_shading_cterm_colors = 8

The g:easy_inline_motion_shading_gui_colors option

  1. What are cterm and gui in the sense of highlighting?
let g:easy_inline_motion_shading_gui_colors = '#808080'

The number of the preview lines

The g:easy_inline_motion_preview_lines option

"" 1 value to preview 1 upper and 1 below lines.
let g:easy_inline_motion_preview_lines = 1

The ignorance of files

This plugin will not work on the files with types and names specified in below options. Set up the values for below options before loading the plugin, unless you do not want the default appended values.

The g:easy_inline_motion_ignore_filetypes option

"" The values are case insensitive.
"" By default, values of 'qf', 'nerdtree', 'help' are appended
let g:easy_inline_motion_ignore_filetypes = ['text']

The g:easy_inline_motion_ignore_filenames option

"" The values are treated as regular expressions and case insensitive.
"" By default, value of '^zsh$' is appended
let g:easy_inline_motion_ignore_filenames = ['^todo$', '^sh$'] " value 'sh' to ignore terminals running on sh

Commands

The EasyInlineMotionOn command

This commands turns on the auto highlighting.

:EasyInlineMotionOn

The EasyInlineMotionOff command

This commands turns off the auto highlighting.

:EasyInlineMotionOff

The EasyInlineMotionShadingOn command

This commands turns on the shading.

:EasyInlineMotionShadingOn

The EasyInlineMotionShadingOff command

This commands turns off the shading.

:EasyInlineMotionShadingOff

License

MIT