Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am analyzing log file using vim and the format looks like this


Since Most of the times I don't care about date and time. I want to hide them and just focus on the Name and LogText columns (To save some screen estate). Since the first three columns always occupy the first 35 letters in a line. Is there a way to make vim not display first 35 letters of each line ?

share|improve this question
I don't know how you do it in vim, but if you don't mind creating a temporary file, you could run cut -c36- logfile > logfile_with_first_35_chars_missing, and then review that. – Warwick Jul 28 '14 at 23:29
up vote 4 down vote accepted

You asked about how to hide the first letters, not to remove them, or scroll them out of sight - so here is how to actually hide it:

Hide text in vim using conceal

You can use matching, combined with syntax highlighting and the conceal feature to actually not show matched characters inside lines.

To hide the first 25 chars of each line:

:syn match Concealed '^.\{25\}' conceal
:set conceallevel=2

To hide only the lines with the punctuation of a date instead:

:syn match Concealed '^....-..-.. ..:..:..\..... ' conceal

To unhide:

:syn clear Concealed
:set conceallevel=0

What looks like this normally:


will look like this after executing the first two commands:

PID Name LogText
PID Name LogText
PID Name LogText
PID Name LogText
PID Name LogText
PID Name LogText
PID Name LogText

See also - inside vim:
help :syn-match
help :syn-conceal
help 'conceallevel'
help 'concealcursor'

(Let me know if it does not behave like that - there may be some more setting i'm not aware of or so - I'll get it to work.)

share|improve this answer
Works fine, I think vim needs to be compiled with +conceal (mine is) option for this to work. Also good to do set concealcursor=nc to prevent the cursor line from expanding. – user881300 Jul 30 '14 at 19:34
Yes, the +conceal feature option is standard like some years. Sad that it's not more well-known by now. It's really great and flexible. Gives lots of new options... – Volker Siegel Jul 30 '14 at 20:14

Use vim's filter functionality. Run:

:%!cut -b36-

to run the contents of your buffer through the cut command, retaining only bytes 36 and onwards. % means to run the entire buffer through and replace its contents with the output, then ! is the filter command, with the rest of the line as the program to run. This doesn't modify the underlying file unless you then save the buffer over the top.

To get the original untrimmed buffer back you can use :e, provided that it's backed by a real file.

share|improve this answer
And then use %!cat % to get it back ? This works great and I can use a map to toggle between these two – user881300 Jul 29 '14 at 0:11
Yes, that will work, as long as you have a real file backing your buffer. – Michael Homer Jul 29 '14 at 0:14
@Michael Homer: This will now work with unicode characters. – cuonglm Jul 29 '14 at 2:03

I think more in line with what you're looking for is horizontal scrolling.

Z is the horizontal scrolling command key, followed by a direction to move with the left or right arrow key.

First :set nowrap to disable line wrapping. Then press z,35, to scroll 35 spaces.

share|improve this answer
This is very useful when reading logs, thank you! – Fabio F. Jul 29 '14 at 9:43
ok, great for a single page, but... How to do page down or page up without the cursor jumping again to the beginning of the line? – elysch Mar 2 at 13:52
just found how to do it in the @user2987828 answer: using :set nosol – elysch Mar 2 at 14:19

In command mode, try:

  • %s/pat/sub/: replace each occurence of pat with sub
  • ^.\{35}: match first 35 characters of line

This command remove first 35 characters of each line. You can read :h regular-expression for more details about regular expression in vim.

share|improve this answer

There is an easy to remember solution, without modifying buffers or files. Place your cursor on the first character (L on your example) of the file portion you want to see, then type

:set nowrap

The zs command will setup vi so that that the character with the cursor appears at first column of the screen. Be sure that you didn't type :set nosol in your configuration files.

The g$ command will move your cursor to the last visible column.

The g0 command will move back your cursor to the first visible column, the one containing L.

If any key moves the cursor to left or right out of the visible columns, then the visible windows will shift.

share|improve this answer
And g0 command will move your cursor to the first visible column – elysch Mar 2 at 14:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.