Skip to content

vim-sade. Smooth operators with minimum waste and maximum joy.

Notifications You must be signed in to change notification settings

neitanod/vim-sade

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 

Repository files navigation

" Relatively simple operators can be defines as mappings
" they are called with "normal!", so we must escape special chars with \

" Let's define "Paste before" and "Paste after" operator mappings
call sade#Map("(p","\<esc>`<P")
call sade#Map(")p","\<esc>`>p")

" This one will convert "script" into "<script>|</script>"
" (the | represents the cursor position after invoking)
call sade#Map("Qt", "di<\<esc>gpi>\<esc>mpa</\<esc>gpi>\<esc>`pll\<cr>")


" Let's define an operator function:
call UserOperatorFunc('b','Test')

func! Test()
  " Target text is selected in visual mode now, 
  " you can yank it, delete it or do anything you want
  " including exiting to normal mode with:  exe 'norm! \<esc>'
  
  " Also, you have some predefined variables:
  "  g:UserOperatorLastText        A copy of the selected text
  "  g:UserOperatorStartingLine    Buffer line number of selection start
  "  g:UserOperatorEndingLine      Buffer line number of selection end 
  "  g:UserOperatorStartingColumn  Buffer column number of selection start
  "  g:UserOperatorEndingColumn    Buffer column number of selection end 
  
  " as usual, marks '< and '> are set at the start and end of the selection
  " so you can choose to position yourself at the beginning or end of the 
  " selection when you're done:    
  " go to the beginning:    norm! `<    
  " go to the end:          norm! `> 

  " (in this example we are going to paste into the line below as an argument
  " to a function call)"

  
  exe "norm! \<esc>"
  let @w = "Inspect::view(".g:UserOperatorLastText.");"
  norm! o
  norm! "wp
  "norm! `<
endfun

About

vim-sade. Smooth operators with minimum waste and maximum joy.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published