vim-pandoc icon indicating copy to clipboard operation
vim-pandoc copied to clipboard

Implement useful mappings, operators and text-objects

Open fmoralesc opened this issue 11 years ago • 4 comments

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

Text objects

  • [ ] list items
  • [ ] definitions
  • [ ] codeblocks
  • [x] spans
  • [x] 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

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

Commands

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

  • [x] Create a reference.
  • [x] Navigate references.
  • [x] Apply a header level
  • [x] Navigate headers.
  • [ ] Toggle ordered/unordered list items
  • [ ] Create list items
  • [x] Navigate lists.
  • [ ] Turn implicit links into explicit.
  • ~~Handle tables.~~ (see https://github.com/vim-pandoc/vim-pandoc/issues/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)

fmoralesc avatar Nov 21 '13 17:11 fmoralesc

  • 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 avatar Aug 28 '14 09:08 0xgrm

@uryupinsk :+1:

fmoralesc avatar Aug 28 '14 16:08 fmoralesc

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>

Konfekt avatar Sep 27 '17 13:09 Konfekt

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

starsareintherose avatar Aug 21 '21 03:08 starsareintherose