Giter VIP home page Giter VIP logo

vim-textmanip's Introduction

Move/Duplicate text intuitively.

  • Move selected lines or block area to specified direction ( up/down/right/left ).
  • Duplicate selected lines or block to specified direction ( up/down/right/left ).
  • Two mode: inesrt or replace
  • Count support
  • Keep original cursor position (include 'o'ther pos in visualmode!) while moving / duplicating.
  • Undo with one 'u' by undojoining.

Example

help

Configuration example

GUI macvim ( which I use now )

xmap <D-d> <Plug>(textmanip-duplicate-down)
nmap <D-d> <Plug>(textmanip-duplicate-down)
xmap <D-D> <Plug>(textmanip-duplicate-up)
nmap <D-D> <Plug>(textmanip-duplicate-up)

xmap <C-j> <Plug>(textmanip-move-down)
xmap <C-k> <Plug>(textmanip-move-up)
xmap <C-h> <Plug>(textmanip-move-left)
xmap <C-l> <Plug>(textmanip-move-right)

" toggle insert/replace with <F10>
nmap <F10> <Plug>(textmanip-toggle-mode)
xmap <F10> <Plug>(textmanip-toggle-mode)

" use allow key to force replace movement
xmap  <Up>     <Plug>(textmanip-move-up-r)
xmap  <Down>   <Plug>(textmanip-move-down-r)
xmap  <Left>   <Plug>(textmanip-move-left-r)
xmap  <Right>  <Plug>(textmanip-move-right-r)

gVim

xmap <M-d> <Plug>(textmanip-duplicate-down)
nmap <M-d> <Plug>(textmanip-duplicate-down)
xmap <M-D> <Plug>(textmanip-duplicate-up)
nmap <M-D> <Plug>(textmanip-duplicate-up)

xmap <C-j> <Plug>(textmanip-move-down)
xmap <C-k> <Plug>(textmanip-move-up)
xmap <C-h> <Plug>(textmanip-move-left)
xmap <C-l> <Plug>(textmanip-move-right)

" toggle insert/replace with <F10>
nmap <F10> <Plug>(textmanip-toggle-mode)
xmap <F10> <Plug>(textmanip-toggle-mode)

" use allow key to force replace movement
xmap  <Up>     <Plug>(textmanip-move-up-r)
xmap  <Down>   <Plug>(textmanip-move-down-r)
xmap  <Left>   <Plug>(textmanip-move-left-r)
xmap  <Right>  <Plug>(textmanip-move-right-r)

vim on terminal

xmap <Space>d <Plug>(textmanip-duplicate-down)
nmap <Space>d <Plug>(textmanip-duplicate-down)
xmap <Space>D <Plug>(textmanip-duplicate-up)
nmap <Space>D <Plug>(textmanip-duplicate-up)

xmap <C-j> <Plug>(textmanip-move-down)
xmap <C-k> <Plug>(textmanip-move-up)
xmap <C-h> <Plug>(textmanip-move-left)
xmap <C-l> <Plug>(textmanip-move-right)

" toggle insert/replace with <F10>
nmap <F10> <Plug>(textmanip-toggle-mode)
xmap <F10> <Plug>(textmanip-toggle-mode)

keymap advanced macvim (this is my current configuration).

nmap <CR>   <Plug>(textmanip-blank-below)
nmap <S-CR> <Plug>(textmanip-blank-above)
xmap <CR>   <Plug>(textmanip-blank-below)
xmap <S-CR> <Plug>(textmanip-blank-above)

nmap <D-D> <Plug>(textmanip-duplicate-up)
nmap <D-d> <Plug>(textmanip-duplicate-down)
xmap <D-D> <Plug>(textmanip-duplicate-up)
xmap <D-d> <Plug>(textmanip-duplicate-down)

xmap <C-k> <Plug>(textmanip-move-up)
xmap <C-j> <Plug>(textmanip-move-down)
xmap <C-h> <Plug>(textmanip-move-left)
xmap <C-l> <Plug>(textmanip-move-right)

xmap <D-K> <Plug>(textmanip-duplicate-up)
xmap <D-J> <Plug>(textmanip-duplicate-down)
xmap <D-H> <Plug>(textmanip-duplicate-left)
xmap <D-L> <Plug>(textmanip-duplicate-right)
                              
xmap  <Up>    <Plug>(textmanip-move-up-r)
xmap  <Down>  <Plug>(textmanip-move-down-r)
xmap  <Left>  <Plug>(textmanip-move-left-r)
xmap  <Right> <Plug>(textmanip-move-right-r)
                              
nmap <C-s> <Plug>(textmanip-toggle-mode)
xmap <C-s> <Plug>(textmanip-toggle-mode)

Experimental hook/helper

Currently only finish hook point is supported. finish is called just before manipulation finish. If you want to additional text manipulation, you can start from following example. The hook must accept one argument(tm in this example), which is texmanip app instance itself.

let g:textmanip_hooks = {}
function! g:textmanip_hooks.finish(tm)
  let tm = a:tm
  let helper = textmanip#helper#get()
  if tm.linewise
    " if filetype is `html` automatically indent
    if &ft ==# 'html'
      call helper.indent(tm)
    endif
  else
    " When blockwise move/duplicate, remove trailing white space.
    " To use this feature without feeling counterintuitive,
    " I recommend you to ':set virtualedit=block',
    call helper.remove_trailing_WS(tm)
  endif
endfunction

vim-textmanip's People

Contributors

arcthur avatar karchz avatar sbdchd avatar t9md 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

vim-textmanip's Issues

Normal Mode Moving

Would it be possible to allow movement in normal mode? Defaults to entire line, without a visual selection? Something like:

" Applied to entire current line in normal mode
nmap <A-j> <Plug>(textmanip-move-down)
nmap <A-k> <Plug>(textmanip-move-up)
nmap <A-h> <Plug>(textmanip-move-left)
nmap <A-l> <Plug>(textmanip-move-right)

Terminal bell rings with each invocation

When running a mapping for seemingly any textmanip command, e.g. <Plug>(textmanip-move-down), the terminal bell rings, which makes using this plugin very annoying. This occurs in both normal and visual mode. Setting belloff=esc disables this beep, which indicates the cause is hitting from normal mode.

I see that textmanip.vim frequently runs execute "normal! \<Esc>" in several functions, and in some cases it's not obvious that the mode isn't already normal.

textmanip-blank-below/aboveとEnterへマップした場合のビープ音について

Vim7.4(MacVim-KaoriYa 20160312)にて vim-textmanip を導入し、
以下のマップを設定しています。

nmap <CR>   <Plug>(textmanip-blank-below)
nmap <S-CR> <Plug>(textmanip-blank-above)
xmap <CR>   <Plug>(textmanip-blank-below)
xmap <S-CR> <Plug>(textmanip-blank-above)

vim-textmanip を 2.0 から 2.5 へアップデートすると、
Enter を押下した際に空行が挿入されると同時にビープ音が
鳴るようになってしまいました。

全く同じ設定・環境でバージョンを 2.0 へ戻すと発生せず、
また 2.5 ままで過去の MacVim へダウングレードしても
ビープ音が鳴ってしまう状況です。

お時間があるときにでも調査いただければ幸いです。

actionの追加要望

左右の移動にて、一行ではなく選択箇所だけを移動させたいです。
今は計算式の順序入れ替えなどで、切り貼りして順番を入れ替えていますが、そういったアクションがあれば直感的に順番の入れ替えができます。

検討お願いします。

Auto-Indent

I'd like an option to re-indent code automatically during movement. I think this only makes sense in non-block (entire line) non-replace (move) mode. Perhaps something like:

" allow binding to force automatic re-indent
" Only available linewise, falls back to default behaviour blockwise
xmap <C-j> <Plug>(textmanip-move-down-indent)
xmap <C-k> <Plug>(textmanip-move-up-indent)

" toggle auto/manual indent for:
"    textmanip-move-down
"    textmanip-move-up
nmap <S-F10> <Plug>(textmanip-move-toggle-ident)
xmap <S-F10> <Plug>(textmanip-move-toggle-indent)

My jaw dropped when I found this plug-in. Vastly superior - should be more popular.

move the block right/left characterwise

The current implementation moves the block left right by shiftwidth.
Sometimes it is needed to move the block by 1 character left/right. It would be very nice if it could be done with textmanip without explicit shiftwidth change.

Thanks for the nice addon.

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.