Compare commits

..

9 Commits
v3.2 ... v3.2.4

Author SHA1 Message Date
Dhruva Sagar
5a6a9b3473 Fixed motions to wrap around edges incorporating table header 2013-10-07 15:07:55 +05:30
Dhruva Sagar
aa8817621c Fixed doc #11 2013-09-25 09:29:37 +05:30
Dhruva Sagar
54187d0be1 Updated Header Border to be like org-mode table header separator for consistency. 2013-09-19 16:53:28 +05:30
Dhruva Sagar
3e2eaeee5c Fixed delete column api with header changes 2013-09-19 15:03:13 +05:30
Dhruva Sagar
6dfc508af5 Fixed headerExpr to incorporate comments & spaces around header border 2013-09-19 13:55:07 +05:30
Dhruva Sagar
ed441f19a1 Added travis status to README 2013-09-19 13:26:42 +05:30
Dhruva Sagar
e4525c465a Fixed travis.yml file, issue with tabs 2013-09-19 13:24:20 +05:30
Dhruva Sagar
19bfa092a3 Updating CHANGELOG 2013-09-19 13:23:19 +05:30
Dhruva Sagar
f91ec2458f Updated README & CHANGELOG 2013-09-19 12:33:28 +05:30
5 changed files with 66 additions and 25 deletions

View File

@@ -1,4 +1,9 @@
# Change Log # 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 ## Version 3.1
* Removed borders. You can now optionally create a table header by simply * Removed borders. You can now optionally create a table header by simply
adding a header border immidiately after the header line by using the adding a header border immidiately after the header line by using the

View File

@@ -1,4 +1,4 @@
# VIM Table Mode # VIM Table Mode [![Build Status](https://travis-ci.org/dhruvasagar/soulmate_rails.png?branch=master)](https://travis-ci.org/dhruvasagar/soulmate_rails)
An awesome automatic table creator & formatter allowing one to create neat An awesome automatic table creator & formatter allowing one to create neat
tables as you type. tables as you type.
@@ -11,17 +11,21 @@ CHANGELOG.md </a>
## Getting Started ## Getting Started
### Installation ### Installation
There are 2 ways to do this There are several ways to do this
1. I recommend installing <a 1. I recommend installing <a
href="https://github.com/tpope/vim-pathogen">pathogen.vim</a> and then href="https://github.com/Shougo/neobundle.vim">NeoBundle</a> and then just
adding a git submodule for your plugin: 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 ```sh
$ cd ~/.vim $ cd ~/.vim
$ git submodule add git@github.com:dhruvasagar/vim-table-mode.git bundle/table-mode $ 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 respective ~/.vim/autoload/, ~/.vim/plugin and ~/.vim/doc under UNIX or
vimfiles/autoload/, vimfiles/plugin/ and vimfiles/doc under WINDOWS and vimfiles/autoload/, vimfiles/plugin/ and vimfiles/doc under WINDOWS and
restart VIM restart VIM

View File

@@ -113,9 +113,6 @@ function! s:StartExpr() "{{{2
endif endif
endfunction 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 function! s:EndExpr() "{{{2
let cend = s:GetCommentEnd() let cend = s:GetCommentEnd()
@@ -126,6 +123,14 @@ function! s:EndExpr() "{{{2
endif endif
endfunction 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 function! s:StartCommentExpr() "{{{2
let cstartexpr = s:GetCommentStart() let cstartexpr = s:GetCommentStart()
if s:Strlen(cstartexpr) > 0 if s:Strlen(cstartexpr) > 0
@@ -165,12 +170,12 @@ function! s:ToggleMapping() "{{{2
execute "inoremap <silent> <buffer> " . b:table_mode_separator_map . ' ' . execute "inoremap <silent> <buffer> " . b:table_mode_separator_map . ' ' .
\ b:table_mode_separator_map . "<Esc>:call tablemode#TableizeInsertMode()<CR>a" \ 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" \ g:table_mode_fillchar . " <Esc>:call tablemode#AddHeaderBorder('.')<CR>A"
else else
execute "iunmap <silent> <buffer> " . b:table_mode_separator_map 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 endif
endfunction endfunction
@@ -185,6 +190,7 @@ function! s:GenerateHeaderBorder(line) "{{{2
let line_val = getline(line - s:RowGap()) 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(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_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() let cstartexpr = s:StartCommentExpr()
if s:Strlen(cstartexpr) > 0 && getline(line) =~# cstartexpr if s:Strlen(cstartexpr) > 0 && getline(line) =~# cstartexpr
@@ -686,9 +692,13 @@ function! tablemode#TableRealign(line) "{{{2
endfunction endfunction
function! tablemode#IsATableRow(line) "{{{2 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 endfunction
function! tablemode#IsATableHeader(line) "{{{2
return getline(a:line) =~# s:HeaderBorderExpr()
endfunction
function! tablemode#LineNr(row) "{{{2 function! tablemode#LineNr(row) "{{{2
if tablemode#IsATableRow('.') if tablemode#IsATableRow('.')
@@ -754,7 +764,9 @@ function! tablemode#TableMotion(direction) "{{{2
if tablemode#IsATableRow('.') if tablemode#IsATableRow('.')
if a:direction ==# 'l' if a:direction ==# 'l'
if s:IsLastCell() if s:IsLastCell()
if !tablemode#IsATableRow(line('.') + s:RowGap()) | return | endif if !tablemode#IsATableHeader(line('.') + s:RowGap()) && !tablemode#IsATableRow(line('.') + s:RowGap())
return
endif
call tablemode#TableMotion('j') call tablemode#TableMotion('j')
normal! 0 normal! 0
endif endif
@@ -767,7 +779,9 @@ function! tablemode#TableMotion(direction) "{{{2
endif endif
elseif a:direction ==# 'h' elseif a:direction ==# 'h'
if s:IsFirstCell() if s:IsFirstCell()
if !tablemode#IsATableRow(line('.') - s:RowGap()) | return | endif if !tablemode#IsATableHeader(line('.') - s:RowGap()) && !tablemode#IsATableRow(line('.') - s:RowGap())
return
endif
call tablemode#TableMotion('k') call tablemode#TableMotion('k')
normal! $ normal! $
endif endif
@@ -779,9 +793,17 @@ function! tablemode#TableMotion(direction) "{{{2
execute 'normal! 2F' . g:table_mode_separator . '2l' execute 'normal! 2F' . g:table_mode_separator . '2l'
endif endif
elseif a:direction ==# 'j' elseif a:direction ==# 'j'
if tablemode#IsATableRow(line('.') + s:RowGap()) | execute 'normal ' . s:RowGap() . 'j' | endif if tablemode#IsATableRow(line('.') + s:RowGap())
execute 'normal ' . s:RowGap() . 'j'
elseif tablemode#IsATableHeader(line('.') + s:RowGap())
execute 'normal ' . (s:RowGap() + 1) . 'j'
endif
elseif a:direction ==# 'k' elseif a:direction ==# 'k'
if tablemode#IsATableRow(line('.') - s:RowGap()) | execute 'normal ' . s:RowGap() . 'k' | endif if tablemode#IsATableRow(line('.') - s:RowGap())
execute 'normal ' . s:RowGap() . 'k'
elseif tablemode#IsATableHeader(line('.') - s:RowGap())
execute 'normal ' . (s:RowGap() + 1) . 'k'
endif
endif endif
endif endif
endfunction endfunction
@@ -802,7 +824,21 @@ endfunction
function! tablemode#DeleteColumn() "{{{2 function! tablemode#DeleteColumn() "{{{2
if tablemode#IsATableRow('.') if tablemode#IsATableRow('.')
for i in range(v:count1) for i in range(v:count1)
call s:MoveToStartOfCell()
if tablemode#IsATableRow(line('.') + 1)
call s:MoveToFirstRow() 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() call s:MoveToStartOfCell()
silent! execute "normal! h\<C-V>f" . g:table_mode_separator silent! execute "normal! h\<C-V>f" . g:table_mode_separator
call s:MoveToLastRow() call s:MoveToLastRow()
@@ -816,15 +852,11 @@ endfunction
function! tablemode#DeleteRow() "{{{2 function! tablemode#DeleteRow() "{{{2
if tablemode#IsATableRow('.') if tablemode#IsATableRow('.')
for i in range(v:count1) for i in range(v:count1)
if tablemode#RowCount('.') ==# 1 if tablemode#IsATableRow('.')
normal! kVjjd normal! dd
else
normal! kVjd
endif endif
if tablemode#IsATableRow(line('.')+1) if !tablemode#IsATableRow('.')
normal! j
else
normal! k normal! k
endif endif
endfor endfor

View File

@@ -29,7 +29,7 @@ GETTING STARTED *table-mode-getting-started*
Create Table on the fly: Create Table on the fly:
Using Table Mode is dead simple. You simply start typing on a new line Using Table Mode is dead simple. You simply start typing on a new line
with the table separator - |g:table-mode-separator|, and you just type with the table separator - |table-mode-separator|, and you just type
away! The plugin does the rest automatically for you as you type. With away! The plugin does the rest automatically for you as you type. With
each additional separator you add, it aligns the table properly, each additional separator you add, it aligns the table properly,
without having to do anything else. without having to do anything else.