Editing Tabular Data in Vim

Editing Tabular Data in Vim
  • 0.00 / 5 5
0 votes, 0.00 avg. rating (0% score)

Helpful settings for editing tabular data:

Noexpandtab disables expanding of inputted tabs to spaces. Adjust the number of spaces to your liking. Tabstop sets the visual appearance of tab stops (here 16 spaces).

Show tabs visually, disable cursor line:

Jump one column left or right Ctrl+H / Ctrl+L in both normal and visual modes to make navigation easier:

Jump 10 lines up or down with Ctrl+K / Ctrl+J:

Disable the behaviour of going to start of line after jumps to make it easier to work on columns:

Now you can G or gg and have your cursor in the same column where it was. Makes it easy to select, yank, delete and move columns. Just don’t add an empty line at the bottom of the file (you can use “set virtualedit=all” to work around that as well if you want).

Excellent blog post on the subject:

 

3 thoughts on “Editing Tabular Data in Vim”

  1. Another way to visualize tabs and other whitespace is with the “listchars” and “list” commands:


    setlocal listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<
    setlocal list

    With this there is no need to hide the cursor line. Also you can see the end of line markers and easily distinguish between tabs and regular space chars.

  2. To use the right mouse button to select text in block visual mode using the mouse:


    nmap <RightMouse> <LeftMouse><C-V>

    Also, by default, quad-clicking the left mouse button (yes, clicking the left mouse button four times :) so that the button is kept depressed after the fourth click does the same.


  3. set virtualedit=all

    or


    set virtualedit=block

    May also be helpful when selecting blocks when some lines are longer than others.

Leave a Reply