Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ it and just execute the command as follows when you need it.

## Configuration

The duration of the cursor flash can be customized in your `~/.vimrc`:
The duration and color of the cursor flash can be customized in your `~/.vimrc`:

" This is the default
" This is the default duration
let g:ping_cursor_flash_milliseconds = 250
" Set named color to the cursor flash
let g:ping_cursor_color = 'lightblue'

## Why I Built This

Expand Down
17 changes: 17 additions & 0 deletions plugin/vim-ping-cursor.vim
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,27 @@ if !exists('g:ping_cursor_flash_milliseconds')
endif

function! s:PingCursor()
if exists('g:ping_cursor_color') && !empty(g:ping_cursor_color)
" Save current CursorLine and CursorColumn attributes.
let l:cur_cursorline = matchstr(execute('hi CursorLine'), 'term=.*')
let l:cur_cursorcolumn = matchstr(execute('hi CursorColumn'), 'term=.*')
" Change the color
execute 'highlight CursorLine ctermbg=' . g:ping_cursor_color . ' guibg=' . g:ping_cursor_color
execute 'highlight CursorColumn ctermbg=' . g:ping_cursor_color . ' guibg=' . g:ping_cursor_color
endif

set cursorline cursorcolumn
redraw
execute 'sleep' g:ping_cursor_flash_milliseconds . 'm'
set nocursorline nocursorcolumn

" Restore previous highlight attributes
if exists('l:cur_cursorline') && !empty(l:cur_cursorline)
execute 'highlight CursorLine ' . l:cur_cursorline
endif
if exists('l:cur_cursorcolumn') && !empty(l:cur_cursorcolumn)
execute 'highlight CursorColumn ' . l:cur_cursorcolumn
endif
endfunction


Expand Down