I am using DrawIt plugin in Vim 7 to draw some ASCII diagrams.
This might be too much, but still—
Is there any plugin which can display a grid in background, to make the drawing easier?
I am using DrawIt plugin in Vim 7 to draw some ASCII diagrams.
This might be too much, but still—
Is there any plugin which can display a grid in background, to make the drawing easier?
I can't add anything to @David and @romainl's thoughts (I think @romainl's suggestion of using a semi-transparent window with a grid behind it is inspired!).
However, you might find it easier to visualise the cursor position by using:
set cursorline
set cursorcolumn
Of course it's not a substitute for a true grid, but it will at least let you see at a glance the alignment of the cursor.
Let me propose an implementation emulating the guiding grid using Vim highlighting features. The following function creates the necessary highlighting taking two mandatory arguments and another two optional ones. The former two are distances between horizontal and vertical lines, correspondingly. The latter arguments are the height and the width of the area covered with grid (in lines and characters, correspondingly). When these arguments are not specified the number of lines in the buffer and the length of the longest line in it are used.
function! ToggleGrid(...)
if exists('b:grid_row_grp') || exists('b:grid_prev_cc')
call matchdelete(b:grid_row_grp)
let &colorcolumn = b:grid_prev_cc
unlet b:grid_row_grp b:grid_prev_cc
return
endif
let [dr, dc] = [a:1, a:2]
if a:0 < 4
let [i, nr, nc] = [1, line('$'), 0]
while i <= nr
let k = virtcol('$')
let nc = nc < k ? k : nc
let i += 1
endwhile
else
let [nr, nc] = [a:3, a:4]
endif
let rows = range(dr, nr, dr)
let cols = range(dc, nc, dc)
let pat = '\V' . join(map(rows, '"\\%" . v:val . "l"'), '\|')
let b:grid_row_grp = matchadd('ColorColumn', pat)
let b:grid_prev_cc = &colorcolumn
let &colorcolumn = join(cols, ',')
endfunction
I'm inclined to agree with @romainl; I can't think of any way to do this truly in Vim without mucking around with the source. However, I can think of a few workarounds.
In many terminal emulators, you can set a background image. (xfce4-terminal
has this feature, for example). You could design a background where the dimensions of each cell correspond to the space occupied by your monospace font.
Nate Kane's vim-indent-guide might be helpful- it displays vertical lines you could use to align characters. See the screenshots page for some examples.
You could abuse Vim's highlighting to simulate a grid of sorts.