Git Product home page Git Product logo

textobj-word-column.vim's Introduction

textobj-word-column.vim

The word-based column text-object makes operating on columns of code conceptually simpler and reduces keystrokes.

textobj-word-column

The common task of deleting, changing, or adding to a vertical column of code can be achieved using visual-blocks, however the first step is to establish the visual block itself. This typically involves moving the cursor to the start of the block, and then using vim motions to move the cursor to the end of the block, and finally doing the appropriate operation.

With a text object for columns, establishing the visual block is much easier, and even unecessary for certain operations.

Usage

This plugin adds ic, ac, iC, and aC as text-objects. Use them in commands like vic, cic, and daC.

Learn more in the plugin doc:

https://github.com/coderifous/textobj-word-column.vim/blob/master/doc/textobj-word-column.txt

textobj-word-column.vim's People

Contributors

andrewradev avatar coderifous avatar inkarkat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

textobj-word-column.vim's Issues

Doesn't work with tabs

Great plugin! I love the idea, but unfortunately it doesn't work with tabs. Looks like it's because when using | to jump to a column, it uses screen columns (instead of actual columns -- see :help bar). Maybe you could multiply the number of tab characters by the value of tabstop?

Repro:
Edit word-column.vim
Put cursor on first 'let' in file.
vic selects all of the lets.
%sm/^ /\t to switch to tabs.
Put cursor on first 'let' in file.
vic selects some weird stuff (on ca711dd it selects a bunch of stuff late in the file and on 69c30da it selects from the beginning of the line).

Summing a column

I wonder whether it would be possible to sum a column, putting the result in the unnamed register "".

Right now I can't think of a way because : will seemingly always operate on new lines, but perhaps someone has a better idea?

E132 on large text selections: too much recursion

s:find_boundary_row is recursive and can cause E132: Function call depth is higher than 'maxfuncdepth' on selections using more than &maxfuncdepth lines. (maxfuncdepth defaults to 100) Looks like function could be done iteratively instead.

Also, not really relevant to this issue, but have you seen textobj-user? Might be useful to take care of some boilerplate stuff?

Incomplete selection at EOL?

On this text:

    id:                 String,
    node:               String,
    lastTried:          sql.Timestamp,
    lastTriedUri:       String,
    lastTriedSeeding:   sql.Timestamp,
    lastTriedDepth:     Int,
    lastFetched:        Option[sql.Timestamp],
    lastFetchedStatus:  Option[Int],
    lastParsed:         Option[sql.Timestamp],
    lastParsedOutLinks: Option[Int]

I do viC from here:

Screen Shot 2013-03-01 at 12 58 08 PM

and get this selection:

Screen Shot 2013-03-01 at 12 58 27 PM

whereas I was expecting a selection more like this:

Screen Shot 2013-03-01 at 12 59 58 PM

Selects unaligned text

(Using ea8ff3d.)

Given this text:

let ctrlp_extensions = ['funky', 'register']
nmap <C-o>l :CtrlPLastMode<CR>
nmap <C-o>b :CtrlPBuffer<CR>
nmap <C-o>f :call ctrlp#init(ctrlp#funky#id())<CR>
nmap <C-o>r :CtrlPRegister<CR>

If I put my cursor on the first < and type vic, then part of the first line is selected. I would expect the column of < to be selected. Instead, the selected block includes ctrlp_extensions and all five lines. Since the word boundaries are in different columns, I think this is incorrect.

Using textobj-user

Hi,

Have you already considered using the vim-textobj-user plugin (see https://github.com/kana/vim-textobj-user)?
I think it would be interesting, for several reasons:

  • ability to customize mappings (for me, ac and ic conflict with the mappings of https://github.com/thinca/vim-textobj-comment)
  • better reuse of code (your plugin becomes smaller and loads faster, since it reuses existing code)
  • use of the autoload feature in vim, for faster startup
  • any improvement in textobj would also benefit your plugin automatically
  • better visibility for your plugin, since it could be listed on https://github.com/kana/vim-textobj-user/wiki

Select based on word under cursor?

(Using ea8ff3d.)

Given this text:

let g:ctrlp_extensions = ['funky', 'register']
nmap <C-o>l :CtrlPLastMode<CR>
nmap <C-o>b :CtrlPBuffer<CR>
nmap <C-o>f :call ctrlp#init(ctrlp#funky#id())<CR>
nmap <C-o>r :CtrlPRegister<CR>

If I put my cursor on the first < and type vic, then the : and the column of < beneath it are selected. But what I wanted was just the column of <.
I would expect viC to do what I want, but instead it selects g:ctrlp_extensions and all of the lines below it. I'm not certain if that's correct. Maybe that's related to #1.

Is there any way to do what I want? vaC does the same thing as viC in this case. vac selects g: and the lines below it. It seems like I want the selection priority to be on the word that my cursor is on.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.