All Projects → kana → Vim Textobj User

kana / Vim Textobj User

Vim plugin: Create your own text objects

Projects that are alternatives of or similar to Vim Textobj User

Vim Devicons
Adds file type icons to Vim plugins such as: NERDTree, vim-airline, CtrlP, unite, Denite, lightline, vim-startify and many more
Stars: ✭ 4,473 (+289.3%)
Mutual labels:  vim-plugins
Evervim
A Modern, Powerful & Modular Vim Distribution
Stars: ✭ 568 (-50.57%)
Mutual labels:  vim-plugins
Vimcompletesme
You don't Complete Me; Vim Completes Me! A super simple, super minimal, super light-weight tab completion plugin for Vim.
Stars: ✭ 752 (-34.55%)
Mutual labels:  vim-plugins
Nerdcommenter
Vim plugin for intensely nerdy commenting powers
Stars: ✭ 4,454 (+287.64%)
Mutual labels:  vim-plugins
Vim Markdown Preview
A light Vim plugin for previewing markdown files in a browser - without leaving Vim.
Stars: ✭ 530 (-53.87%)
Mutual labels:  vim-plugins
Alchemist.vim
Elixir Integration Into Vim
Stars: ✭ 632 (-45%)
Mutual labels:  vim-plugins
Winresizer
very simple vim plugin for easy resizing of your vim windows
Stars: ✭ 353 (-69.28%)
Mutual labels:  vim-plugins
Vim Solargraph
vim plugin (wrapper) for Solargraph gem - IDE tools for the Ruby language.
Stars: ✭ 48 (-95.82%)
Mutual labels:  vim-plugins
Dotfiles
💾 Ian's dotfiles, utils, and Zsh/Vim/tmux configs
Stars: ✭ 554 (-51.78%)
Mutual labels:  vim-plugins
Minpac
A minimal package manager for Vim 8 (and Neovim)
Stars: ✭ 693 (-39.69%)
Mutual labels:  vim-plugins
Vim Ide
VIM configured as powerful IDE (Integrated Development Environment)
Stars: ✭ 441 (-61.62%)
Mutual labels:  vim-plugins
Vim Plugins Profile
🕓 Profile Vim's plugins, generate awesome statistics and optimize (n)vim startup time
Stars: ✭ 508 (-55.79%)
Mutual labels:  vim-plugins
Vim Wakatime
Vim plugin for automatic time tracking and metrics generated from your programming activity.
Stars: ✭ 669 (-41.78%)
Mutual labels:  vim-plugins
Vim Markdown Toc
A vim 7.4+ plugin to generate table of contents for Markdown files.
Stars: ✭ 427 (-62.84%)
Mutual labels:  vim-plugins
Hot Reload.vim
A (Neo)vim plugin for Flutter to automatically hot reload the project every time a file is saved
Stars: ✭ 33 (-97.13%)
Mutual labels:  vim-plugins
Braceless.vim
🐍 Text objects, folding, and more for Python and other indented languages.
Stars: ✭ 376 (-67.28%)
Mutual labels:  vim-plugins
Tagbar
Vim plugin that displays tags in a window, ordered by scope
Stars: ✭ 5,322 (+363.19%)
Mutual labels:  vim-plugins
Vim Systemd Syntax
Syntax highlighting for systemd service files in Vim.
Stars: ✭ 57 (-95.04%)
Mutual labels:  vim-plugins
Vim Strand
A barebones Vim plugin manger written in Rust
Stars: ✭ 38 (-96.69%)
Mutual labels:  vim-plugins
Context.vim
Vim plugin that shows the context of the currently visible buffer contents
Stars: ✭ 688 (-40.12%)
Mutual labels:  vim-plugins

vim-textobj-user - Create your own text objects

Build Status

vim-textobj-user is a Vim plugin to create your own text objects without pain. It is hard to create text objects, because there are many pitfalls to deal with. This plugin hides such details and provides a declarative way to define text objects. You can use regular expressions to define simple text objects, or use functions to define complex ones.

Examples

Simple text objects defined by a pattern

Define ad/id to select a date such as 2013-03-16, and define at/it to select a time such as 22:04:21:

call textobj#user#plugin('datetime', {
\   'date': {
\     'pattern': '\<\d\d\d\d-\d\d-\d\d\>',
\     'select': ['ad', 'id'],
\   },
\   'time': {
\     'pattern': '\<\d\d:\d\d:\d\d\>',
\     'select': ['at', 'it'],
\   },
\ })

Simple text objects surrounded by a pair of patterns

Define aA to select text from << to the matching >>, and define iA to select text inside << and >>:

call textobj#user#plugin('braces', {
\   'angle': {
\     'pattern': ['<<', '>>'],
\     'select-a': 'aA',
\     'select-i': 'iA',
\   },
\ })

Complex text objects defined by functions

Define al to select the current line, and define il to select the current line without indentation:

call textobj#user#plugin('line', {
\   '-': {
\     'select-a-function': 'CurrentLineA',
\     'select-a': 'al',
\     'select-i-function': 'CurrentLineI',
\     'select-i': 'il',
\   },
\ })

function! CurrentLineA()
  normal! 0
  let head_pos = getpos('.')
  normal! $
  let tail_pos = getpos('.')
  return ['v', head_pos, tail_pos]
endfunction

function! CurrentLineI()
  normal! ^
  let head_pos = getpos('.')
  normal! g_
  let tail_pos = getpos('.')
  let non_blank_char_exists_p = getline('.')[head_pos[2] - 1] !~# '\s'
  return
  \ non_blank_char_exists_p
  \ ? ['v', head_pos, tail_pos]
  \ : 0
endfunction

Text objects for a specific filetype

Define a( to select text from \left( to the matching \right), and define i( to select text inside \left( to the matching \right), but only for tex files:

call textobj#user#plugin('tex', {
\   'paren-math': {
\     'pattern': ['\\left(', '\\right)'],
\     'select-a': [],
\     'select-i': [],
\   },
\ })

augroup tex_textobjs
  autocmd!
  autocmd FileType tex call textobj#user#map('tex', {
  \   'paren-math': {
  \     'select-a': '<buffer> a(',
  \     'select-i': '<buffer> i(',
  \   },
  \ })
augroup END

Further reading

You can define your own text objects like the above examples. See also the reference manual for more details.

There are many text objects written with vim-textobj-user. If you want to find useful ones, or to know how they are implemented, see a list of text objects implemented with vim-textobj-user.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].