Further improved visual-execute

- Now also works in insert mode with <C-Space> (only current line)
- Made vim.column more robust and added col alias
This commit is contained in:
Talia 2018-03-12 09:30:49 +01:00
parent d36e470044
commit 3d427643bb
2 changed files with 15 additions and 6 deletions

View file

@ -27,15 +27,18 @@ tree = (tab, level=0, skip="") ->
import max from math
column = (col) ->
if type(col)!="table" then col = {col}
pad = (str, len) ->
str..string.rep(" ", len-#str)
width = 0
for box in *col
if type(box)!="table" then box = {box}
for elem in *box
width = max(width, #elem)
print "┌─"..string.rep("─",width).."─┐"
for idx,box in ipairs(col)
if type(box)!="table" then box={box}
last = idx==#col
for elem in *box
io.write "│ "
@ -58,4 +61,8 @@ draw = ->
print table.concat(line, " ")
{:tree, :column, :box, :draw}
{
:tree, :column, :box, :draw
-- Aliases
col: column
}

8
vimrc
View file

@ -409,14 +409,16 @@ noremap gk k
nnoremap Y y$
" --- VISUAL EXECUTE ---
vnoremap <C-CR> ""y<CR>
\ :call setreg("\"", substitute(getreg("\""), "\n", "", ""), "v")<CR>
\ :<C-r>"<CR>`<
let $LUA_PATH = $LUA_PATH.";".expand("<sfile>:p:h")."/lua/?.lua"
let g:mooncompile = "!moonc ".expand("<sfile>:p:h")."/lua"
command! Mooncompile silent exec g:mooncompile
let g:exe_prg = "moonc -- | lua -l vim -"
vnoremap <CR> :<C-U>exec "'<,'>!".g:exe_prg<CR>
vnoremap <C-CR> ""y<CR>
\ :call setreg("\"", substitute(getreg("\""), "\n", "", ""), "v")<CR>
\ :<C-r>"<CR>`<
inoremap <C-Space> <C-[>0v$:<C-U>exec "'<,'>!".g:exe_prg<CR>
" --- OTHER ---
" Don't exit visual mode when "shifting"