Skip to content

Implement useful mappings, operators and text-objects #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
10 of 18 tasks
fmoralesc opened this issue Nov 21, 2013 · 4 comments
Open
10 of 18 tasks

Implement useful mappings, operators and text-objects #2

fmoralesc opened this issue Nov 21, 2013 · 4 comments

Comments

@fmoralesc
Copy link
Member

I'll keep this issue open for stuff I think should be implemented. Suggestions are most welcome.

Text objects

  • list items
  • definitions
  • codeblocks
  • spans
  • sections

With these, we could, for example, change stuff with natural vim idioms (cipp for changing inside a pandoc paragraph, dipli for deleting a list item, etc.)

Text style operators

  • Apply italics, bold.
  • Apply verbatim formatting,
  • Apply superscript, subscripts, strikeouts, etc.

Commands

Mappings for operations like inserting a table row, creating a reference, etc.

  • Create a reference.
  • Navigate references.
  • Apply a header level
  • Navigate headers.
  • Toggle ordered/unordered list items
  • Create list items
  • Navigate lists.
  • Turn implicit links into explicit.
  • Handle tables. (see Support for assisted table creation #95)

Other

  • indent list item when pressing Tab key in insert mode
  • add the possibility to use different list item characters based on the indentation level (ex: '*' for level 1, '-' for level 2)
@0xgrm
Copy link

0xgrm commented Aug 28, 2014

  • indent list item when pressing Tab key in insert mode
  • add the possibility to use different list item characters based on the indentation level (ex: '*' for level 1, '-' for level 2)

@fmoralesc
Copy link
Member Author

@uryupinsk 👍

@Konfekt
Copy link
Contributor

Konfekt commented Sep 27, 2017

Here are some suggestions:

Section Jumping:

" section jumping
nnoremap <buffer><silent> ]] :<c-u>call <SID>TexJump2Section( v:count1, '' , 0)<CR>
nnoremap <buffer><silent> [[ :<c-u>call <SID>TexJump2Section( v:count1, 'b', 0)<CR>
xnoremap <buffer><silent> ]] :<c-u>call <SID>TexJump2Section( v:count1, '' , 1)<CR>
xnoremap <buffer><silent> [[ :<c-u>call <SID>TexJump2Section( v:count1, 'b', 1)<CR>
onoremap <buffer><silent> ]] :<c-u>normal ]]<CR>
onoremap <buffer><silent> [[ :<c-u>normal [[<CR>

function! s:TexJump2Section( cnt, dir, vis )
  if a:vis
    normal! gv
  endif

  let i = 0
  let pattern = '\v^#{1,6}.*$|^.+\n%(\-+|\=+)$'
  let flags = 'W' . a:dir
  while i < a:cnt && search( pattern, flags ) > 0
    let i = i+1
  endwhile
endfunction

LaTeX environments:

" From https://github.com/gibiansky/vim-latex-objects/blob/da66a67199c7c55f582b8720e4b06819c78f6478/plugin/vim-latex-objects.vim

function! <sid>NextEnd()
    let curline = line(".") + 1
    let begins = 1
    while begins > 0
        if getline(curline) =~ '.*\\begin.*$'
            let begins += 1
        endif
        if getline(curline) =~ '.*\\end.*$'
            let begins -= 1
        endif

        let curline += 1
    endwhile

    return curline - 1
endfunction

function! <sid>PrevBegin()
    let curline = line(".")
    let ends = 1
    while ends > 0
        if getline(curline) =~ '.*\\begin.*$'
            let ends -= 1
        endif
        if getline(curline) =~ '.*\\end.*$'
            let ends += 1
        endif

        let curline -= 1
    endwhile

    return curline + 1
endfunction

function! <sid>SelectInEnvironment(surround)
    let start = <sid>PrevBegin()
    let end = <sid>NextEnd()

    call cursor(start, 0)
    if !a:surround
        normal! j
    end
    normal! V
    call cursor(end, 0)
    if !a:surround
        normal! k
    end
endfunction

" Operate on environments (that have begin and ends on separate lines)
xnoremap <buffer><silent> ie <ESC>:call <sid>SelectInEnvironment(0)<CR>
xnoremap <buffer><silent> ae <ESC>:call <sid>SelectInEnvironment(1)<CR>

nnoremap <buffer> <SID>(V) V
onoremap <buffer> ie :execute "keepjumps normal \<SID>(V)ie"<CR>
onoremap <buffer> ae :execute "keepjumps normal \<SID>(V)ae"<CR>

@starsareintherose
Copy link

Could the bib reference list show in a separate window, such as NERDTree or Tagbar?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants