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.
In general, this plugin works well with the default configuration.
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.
- This plugin highlights characters that built-in cursor motion command,
w
andb
, may jump to. - 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.
- 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
ork
or<up>
or<down>
. See g:easy_inline_motion_preview_lines for its configuration. - The highlighting is off when it is in the insert mode.
- The highlighting can be turned on/off and toggled using commands or mapped keys.
- 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.
For example, with plugin manager, vim-plug:
Plug '8ooo8/vim-inline-easy-motion'
map <Leader>eim <Plug>(easy-inline-motion-toggle-auto-highlight-mode)
map <Leader>sh <Plug>(easy-inline-motion-toggle-shading-mode)
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]
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']
"" 0 value to off, other values to on
let g:easy_inline_motion_shading_on = 1
let g:easy_inline_motion_shading_cterm_colors = 8
let g:easy_inline_motion_shading_gui_colors = '#808080'
"" 1 value to preview 1 upper and 1 below lines.
let g:easy_inline_motion_preview_lines = 1
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 values are case insensitive.
"" By default, values of 'qf', 'nerdtree', 'help' are appended
let g:easy_inline_motion_ignore_filetypes = ['text']
"" 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
This commands turns on the auto highlighting.
:EasyInlineMotionOn
This commands turns off the auto highlighting.
:EasyInlineMotionOff
This commands turns on the shading.
:EasyInlineMotionShadingOn
This commands turns off the shading.
:EasyInlineMotionShadingOff