Code Monkey home page Code Monkey logo

vim-line-jump's Introduction

This is a mirror of http://www.vim.org/scripts/script.php?script_id=5023

When in Tagbar and NERDTree, It's not convenient jump lines using 'j','k'.
LineJump is written to make it easier

First, add following default map to your .vimrc
    "LineJump NERDTree key map
    augroup LineJumpNerdTree
        "I find nerdtree's f map to something not that useful!
        autocmd BufEnter NERD_tree_\d\+ nnoremap <buffer> <nowait> <silent> f <ESC>:silent! call LineJumpSelectForward()<cr>
        autocmd BufEnter NERD_tree_\d\+ nnoremap <buffer> <nowait> <silent> ; <ESC>:silent! call LineJumpMoveForward()<cr>
        autocmd BufEnter NERD_tree_\d\+ nnoremap <buffer> <nowait> <silent> b <ESC>:silent! call LineJumpSelectBackward()<cr>
        autocmd BufEnter NERD_tree_\d\+ nnoremap <buffer> <nowait> <silent> , <ESC>:silent! call LineJumpMoveBackward()<cr>

        autocmd BufEnter NERD_tree_\d\+ nnoremap <buffer> <nowait> <silent> gh <ESC>:silent! call LineJumpMoveTop()<cr>
        autocmd BufEnter NERD_tree_\d\+ nnoremap <buffer> <nowait> <silent> gm <ESC>:silent! call LineJumpMoveMiddle()<cr>
        autocmd BufEnter NERD_tree_\d\+ nnoremap <buffer> <nowait> <silent> gl <ESC>:silent! call LineJumpMoveBottom()<cr>
    augroup END

    "LineJump TagBar key map
    augroup LineJumpTagbar
        autocmd BufEnter __Tagbar__ nnoremap <buffer> <nowait> <silent> f <ESC>:silent! call LineJumpSelectForward()<cr>
        autocmd BufEnter __Tagbar__ nnoremap <buffer> <nowait> <silent> ; <ESC>:silent! call LineJumpMoveForward()<cr>
        autocmd BufEnter __Tagbar__ nnoremap <buffer> <nowait> <silent> b <ESC>:silent! call LineJumpSelectBackward()<cr>
        autocmd BufEnter __Tagbar__ nnoremap <buffer> <nowait> <silent> , <ESC>:silent! call LineJumpMoveBackward()<cr>

        autocmd BufEnter __Tagbar__ nnoremap <buffer> <nowait> <silent> gh <ESC>:silent! call LineJumpMoveTop()<cr>
        autocmd BufEnter __Tagbar__ nnoremap <buffer> <nowait> <silent> gm <ESC>:silent! call LineJumpMoveMiddle()<cr>
        autocmd BufEnter __Tagbar__ nnoremap <buffer> <nowait> <silent> gl <ESC>:silent! call LineJumpMoveBottom()<cr>
    augroup END

It has two map key 'f', 'b' and a group of function to jump quickly in NERDTree and Tagbar(if you like, also can be enable in other buffer)

Here is how it works:
    in NERDTree or Tagbar, press 'f'(forward jump) or 'b'(backward jump), the first alpha will be highlight,
    previous selection often will have more than one match,  than:
        When g:LineJumpSelectMethod is 0:
            1. use ';' to move to next match
            2. use ',' to move to previous match
            3. use 'gh' to move to the first match
            4. use 'gm' to move to the middle match 
            5. use 'gl' to move to the last match
        When g:LineJumpSelectMethod is 1:
            highlight characters will be shown, press the conreponding
            key to jump to the line

Global option:
    g:LineJumpSelectMethod
        define sub select way, default is 0
        0: sub select by LineJumpSubForward(), LineJumpSubBackward()
            need to map these two functions to some key
        1: sub select by press number and alpha

    g:LineJumpSelectInVisable = 0
        only valid when g:LineJumpSelectMethod == 0, 
        if it is not 0, select will extend to the whole buffer,
        not just lines visabled in the window

    g:LineJumpMoveHighlight = 0
        only valid when g:LineJumpSelectMethod == 0, 
        if it is not 0, when move using ';',',', the candidate lines will highlight

[email protected] 2014.09.28
Distributed under the same terms as Vim itself.

vim-line-jump's People

Watchers

 avatar

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.