mirror of
https://github.com/dhruvasagar/vim-table-mode.git
synced 2025-11-08 11:03:47 -05:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
54187d0be1 | ||
|
|
3e2eaeee5c | ||
|
|
6dfc508af5 | ||
|
|
ed441f19a1 | ||
|
|
e4525c465a | ||
|
|
19bfa092a3 | ||
|
|
f91ec2458f |
@@ -1,4 +1,4 @@
|
||||
language: ruby
|
||||
rvm:
|
||||
- 1.9.3
|
||||
- 1.9.3
|
||||
script: rake ci
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
# Change Log
|
||||
## Version 3.2
|
||||
* Added tests to test various use cases using <a
|
||||
href='https://github.com/kana/vim-vspec'>Vspec</a>..
|
||||
* Added travis integration for automated tests.
|
||||
|
||||
## Version 3.1
|
||||
* Removed borders. You can now optionally create a table header by simply
|
||||
adding a header border immidiately after the header line by using the
|
||||
|
||||
14
README.md
14
README.md
@@ -1,4 +1,4 @@
|
||||
# VIM Table Mode
|
||||
# VIM Table Mode [](https://travis-ci.org/dhruvasagar/soulmate_rails)
|
||||
|
||||
An awesome automatic table creator & formatter allowing one to create neat
|
||||
tables as you type.
|
||||
@@ -11,17 +11,21 @@ CHANGELOG.md </a>
|
||||
## Getting Started
|
||||
### Installation
|
||||
|
||||
There are 2 ways to do this
|
||||
There are several ways to do this
|
||||
|
||||
1. I recommend installing <a
|
||||
href="https://github.com/tpope/vim-pathogen">pathogen.vim</a> and then
|
||||
adding a git submodule for your plugin:
|
||||
href="https://github.com/Shougo/neobundle.vim">NeoBundle</a> and then just
|
||||
add `NeoBundle 'dhruvasagar/vim-table-mode'` to your ~/.vimrc
|
||||
|
||||
2. If you are using <a
|
||||
href="https://github.com/tpope/vim-pathogen">pathogen.vim</a>, then
|
||||
add a git submodule for your plugin:
|
||||
|
||||
```sh
|
||||
$ cd ~/.vim
|
||||
$ git submodule add git@github.com:dhruvasagar/vim-table-mode.git bundle/table-mode
|
||||
```
|
||||
2. Copy autoload/todomode.vim, plugin/todo-mode.vim, doc/todo-mode.txt to
|
||||
3. Copy autoload/todomode.vim, plugin/todo-mode.vim, doc/todo-mode.txt to
|
||||
respective ~/.vim/autoload/, ~/.vim/plugin and ~/.vim/doc under UNIX or
|
||||
vimfiles/autoload/, vimfiles/plugin/ and vimfiles/doc under WINDOWS and
|
||||
restart VIM
|
||||
|
||||
@@ -113,9 +113,6 @@ function! s:StartExpr() "{{{2
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:HeaderBorderExpr() "{{{2
|
||||
return '^\s*' . g:table_mode_corner . '[' . g:table_mode_fillchar . g:table_mode_corner . ']*' . g:table_mode_corner . '$'
|
||||
endfunction
|
||||
|
||||
function! s:EndExpr() "{{{2
|
||||
let cend = s:GetCommentEnd()
|
||||
@@ -126,6 +123,14 @@ function! s:EndExpr() "{{{2
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:HeaderBorderExpr() "{{{2
|
||||
return s:StartExpr() .
|
||||
\ '[' . g:table_mode_corner . g:table_mode_separator . ']' .
|
||||
\ '[' . g:table_mode_fillchar . g:table_mode_corner . ']*' .
|
||||
\ '[' . g:table_mode_corner . g:table_mode_separator . ']' .
|
||||
\ s:EndExpr()
|
||||
endfunction
|
||||
|
||||
function! s:StartCommentExpr() "{{{2
|
||||
let cstartexpr = s:GetCommentStart()
|
||||
if s:Strlen(cstartexpr) > 0
|
||||
@@ -165,12 +170,12 @@ function! s:ToggleMapping() "{{{2
|
||||
execute "inoremap <silent> <buffer> " . b:table_mode_separator_map . ' ' .
|
||||
\ b:table_mode_separator_map . "<Esc>:call tablemode#TableizeInsertMode()<CR>a"
|
||||
|
||||
execute "inoreabbrev <silent> <buffer> " . g:table_mode_corner .
|
||||
execute "inoremap <silent> <buffer> " . g:table_mode_corner .
|
||||
\ g:table_mode_fillchar . " <Esc>:call tablemode#AddHeaderBorder('.')<CR>A"
|
||||
else
|
||||
execute "iunmap <silent> <buffer> " . b:table_mode_separator_map
|
||||
|
||||
execute "iunabbrev <silent> <buffer> " . g:table_mode_corner . g:table_mode_fillchar
|
||||
execute "iunmap <silent> <buffer> " . g:table_mode_corner . g:table_mode_fillchar
|
||||
endif
|
||||
endfunction
|
||||
|
||||
@@ -185,6 +190,7 @@ function! s:GenerateHeaderBorder(line) "{{{2
|
||||
let line_val = getline(line - s:RowGap())
|
||||
let border = substitute(line_val[stridx(line_val, g:table_mode_separator):strridx(line_val, g:table_mode_separator)], g:table_mode_separator, g:table_mode_corner, 'g')
|
||||
let border = substitute(border, '[^' . g:table_mode_corner . ']', g:table_mode_fillchar, 'g')
|
||||
let border = substitute(border, '^' . g:table_mode_corner . '\(.*\)' . g:table_mode_corner . '$', g:table_mode_separator . '\1' . g:table_mode_separator , '')
|
||||
|
||||
let cstartexpr = s:StartCommentExpr()
|
||||
if s:Strlen(cstartexpr) > 0 && getline(line) =~# cstartexpr
|
||||
@@ -686,10 +692,10 @@ function! tablemode#TableRealign(line) "{{{2
|
||||
endfunction
|
||||
|
||||
function! tablemode#IsATableRow(line) "{{{2
|
||||
return getline(a:line) =~# (s:StartExpr() . g:table_mode_separator)
|
||||
return getline(a:line) =~# (s:StartExpr() . g:table_mode_separator . '[^' .
|
||||
\ g:table_mode_fillchar . ']*[^' . g:table_mode_corner . ']*$')
|
||||
endfunction
|
||||
|
||||
|
||||
function! tablemode#LineNr(row) "{{{2
|
||||
if tablemode#IsATableRow('.')
|
||||
let line = s:Line('.')
|
||||
@@ -802,7 +808,21 @@ endfunction
|
||||
function! tablemode#DeleteColumn() "{{{2
|
||||
if tablemode#IsATableRow('.')
|
||||
for i in range(v:count1)
|
||||
call s:MoveToFirstRow()
|
||||
call s:MoveToStartOfCell()
|
||||
|
||||
if tablemode#IsATableRow(line('.') + 1)
|
||||
call s:MoveToFirstRow()
|
||||
" If we have a header delete it first
|
||||
if tablemode#IsATableRow(line('.')-2)
|
||||
call cursor(line('.')-2, col('.'))
|
||||
silent! execute "normal! h\<C-V>f" . g:table_mode_separator
|
||||
normal! jdjj
|
||||
endif
|
||||
else " We're already on the header
|
||||
silent! execute "normal! h\<C-V>f" . g:table_mode_separator
|
||||
normal! jdjj
|
||||
endif
|
||||
|
||||
call s:MoveToStartOfCell()
|
||||
silent! execute "normal! h\<C-V>f" . g:table_mode_separator
|
||||
call s:MoveToLastRow()
|
||||
@@ -816,15 +836,11 @@ endfunction
|
||||
function! tablemode#DeleteRow() "{{{2
|
||||
if tablemode#IsATableRow('.')
|
||||
for i in range(v:count1)
|
||||
if tablemode#RowCount('.') ==# 1
|
||||
normal! kVjjd
|
||||
else
|
||||
normal! kVjd
|
||||
if tablemode#IsATableRow('.')
|
||||
normal! dd
|
||||
endif
|
||||
|
||||
if tablemode#IsATableRow(line('.')+1)
|
||||
normal! j
|
||||
else
|
||||
if !tablemode#IsATableRow('.')
|
||||
normal! k
|
||||
endif
|
||||
endfor
|
||||
|
||||
Reference in New Issue
Block a user