What do you do when you want to "just take a look at / fix this file" while working with Claude Code?

2026-04-14
30min read
Updated: 2026-04-15
hf_20260415_032913_aa4e93c3-7aae-4434-bf2a-c38094cfbccb.webp

Table of Contents

When working with Claude Code, you often find yourself wanting to "just quickly check the contents of this file." You can use cat or less for a quick look, but sometimes you want to read it properly with syntax highlighting.

You could just open VS Code or Cursor, but when you have IDEs running across multiple projects, memory consumption starts to add up. Have you ever felt like "I just want to view a file, and firing up an IDE just for that feels too heavy"?

In this article, I'll introduce two solutions that work entirely within the terminal.

  • bat if you just want to browse: An enhanced version of cat. It comes with syntax highlighting and mouse selection works naturally.
  • Neovim if editing is also on the table: A lightweight editor that opens files with syntax highlighting while also letting you make edits when needed.

By the way, the terminal I use is Ghostty. I find it invaluable because it's lightweight and makes splitting the screen easy. Running Claude Code in one pane while opening bat or Neovim in the other to check files is a very comfortable workflow.

The Simplest Options: cat / less / tail

Before getting into bat, let me touch on the commands that come standard. If you just want to see the contents without syntax highlighting, these are sufficient.

# Display the entire file as-is
cat src/index.ts

# When you want to scroll through it
less src/index.ts

# When you just want to check the end
tail -20 src/index.ts

With less, press the spacebar to scroll one screen at a time, and q to quit. You can search by typing / followed by your keyword.

However, these commands have no syntax highlighting. When reading code, the lack of color is subtly painful.

The Definitive Browsing Tool: bat

bat is a clone of cat that comes with syntax highlighting and paging (equivalent to less) built in. It's a representative modern CLI tool written in Rust, and is widely used as the go-to replacement for cat.

Installation is a single command with Homebrew.

brew install bat

Usage is almost the same as cat.

bat src/index.ts

For long files, it automatically enters paging mode, where you scroll with the spacebar and quit with q, just like less. For short files, it outputs directly without going through a pager, just like cat, so it can be used as a drop-in upgrade.

What About Mouse Operations?

bat (which uses less internally) does not capture mouse events. So the terminal handles mouse selection normally. Drag to select → Command+C works as expected. Unlike Neovim, which I'll introduce later, you don't need to remember any modifier keys.

Mouse wheel scrolling also works comfortably in Ghostty without any additional configuration—the currently displayed page scrolls naturally.

If You Want to Use It as a Daily cat Replacement

If you want to use bat with the same feel as cat, setting up an alias is the standard approach.

alias cat='bat --plain --paging=never'

--plain removes decorations (line numbers and grid), and --paging=never outputs directly without going through a pager even for short files. This lets you use it just like cat while benefiting from syntax highlighting.

That said, I don't set up this alias. I want to keep the behavior consistent with how I use cat in shell scripts, and I prefer to consciously type bat only when I want to view something with syntax highlighting—it keeps my intentions clear.

Neovim if Editing Is Also on the Table

bat is a viewing-only tool. When you find yourself thinking "after reading this, I want to make a small edit," it's time for an editor. From here, I'll walk through setting up Neovim. Don't worry if you've never touched a Vim-style editor before.

Why Neovim Instead of Vim?

When you think of terminal-based editors, Vim comes to mind, but in this article I'll be using Neovim. Neovim is a fork of Vim, and the basic operations are the same. The difference lies in how much works out of the box without configuration.

With plain Vim, there are quite a few settings you need to write before it's usable—enabling syntax highlighting, setting autoread, displaying line numbers, fixing backspace behavior, and so on. Neovim has these enabled by default, so you can reach a practical environment with minimal configuration.

If you're a heavy Vim user, you can write the same settings in .vimrc to create the same environment. But since I'm not that familiar with Vim myself, Neovim—which is practical even with default settings—was easier for me. If you're just getting started, I think Neovim is more approachable.

Installing and Launching Neovim

On macOS, a single Homebrew command does it.

brew install neovim

For Ubuntu-based systems:

sudo apt install neovim

Let's verify the installation.

nvim --version

To open a file, launch it with nvim filename.

nvim src/index.ts

Understanding the "Mode" Concept First

When you first encounter Neovim, you might be confused when pressing keys doesn't input text. This is because Neovim has a system called "modes." Right after launching, you're in Normal mode, where all key input is interpreted as "operation commands."

There are only three modes you need to remember.

KeyModePurpose
(right after launch)Normal modeCursor movement, command execution
iInsert modeTyping and editing text
v / VVisual modeRange selection (v for character-wise, V for line-wise)

Pressing Esc from any mode returns you to Normal mode. When in doubt, press Esc twice—that's all you need to remember to avoid getting lost. The status line at the bottom of the screen shows -- INSERT -- or -- VISUAL --, so you can always tell which mode you're in at a glance.

Saving and Quitting

Pressing : in Normal mode brings up the command input line. At a minimum, remember these.

CommandAction
:wSave
:qQuit
:wqSave and quit
:q!Force quit without saving

"I can't figure out how to close it" is a classic Vim experience, but as long as you know :q!, you can always escape.

Configuring Auto-Reload for Claude Code Edits

You might have a file open in Neovim while letting Claude Code work in the adjacent pane. It's convenient to configure Neovim to automatically reload the file when Claude Code modifies it.

The configuration file is ~/.config/nvim/init.vim. If it doesn't exist yet, create the directory along with it.

mkdir -p ~/.config/nvim
nvim ~/.config/nvim/init.vim

Write the following content.

set autoread
set number
syntax on
au CursorHold,CursorHoldI * checktime
au FocusGained,BufEnter * checktime

autoread is enabled by default in Neovim, but I'm writing it here to make the intent explicit. However, autoread alone only triggers a reload at limited moments—such as after running a shell command or when focus is restored. By adding the two au CursorHold and au FocusGained lines, checktime (checking for external changes) also runs when the cursor has been still for a certain period or when the window regains focus.

With this configuration in place and a file open in Neovim, you can watch the contents update each time Claude Code makes edits in the adjacent pane.

The Copy & Paste Philosophy

If you want to do editing in Neovim, you'll need to understand how copy and paste works. The Vim world uses its own unique terminology.

  • Copying is called yanking
  • There's no concept of cut; deleting automatically places the content into a register

In other words, "delete = cut." This shift in thinking might be the first hurdle.

Basic Operations (Normal Mode)

KeyAction
yyCopy current line
ddCut current line (delete and place in register)
xDelete one character
pPaste after cursor
PPaste before cursor

In Visual mode (with a range selected using v), pressing y copies the selection and d cuts it.

Integrating with the Mac Clipboard

The default y and p only work with Neovim's internal registers. To exchange copy and paste with other Mac apps, add one line to init.vim.

set clipboard=unnamedplus

This directly connects y / p / d to the Mac system clipboard. You can yank something in Neovim and paste it into another app with Command+V, or paste something copied in another app into Neovim with p.

If you'd rather not always sync with the clipboard and only want to use it when needed, you can specify it one-off with "+y (yank to system clipboard) or "+p (paste from system clipboard).

Choosing Your Mouse Operation Style

Neovim has mouse operations enabled by default (mouse=nvi). In this state, dragging the mouse is treated as a Neovim Visual mode selection, not a terminal selection.

Pressing Command+C here won't copy anything because there's no selection on the terminal side. Furthermore, if you accidentally press the c key, Neovim interprets it as "change (delete the selection and enter Insert mode)," which can cause the selection to disappear.

In my early days, I couldn't shake the habit of "mouse select → Command+C" and accidentally deleted my selection several times. But don't worry—you get used to it quickly. And even if it happens, you can press Esc to return to Normal mode and then u to undo (u is undo, Ctrl+r is redo—think of them as the equivalent of Mac's Command+Z / Command+Shift+Z).

There are three approaches to handle this.

Recommended: Use the Defaults

Actually, the easiest approach is to leave the mouse setting as mouse=nvi and rely on Vim-style copy and paste (y / d / p). This is where I've settled as well.

  • Mouse drag to visually select → just press y to put it in the Mac clipboard (thanks to clipboard=unnamedplus)
  • Mouse click to position the cursor, so editing feels like a normal editor

It's just a matter of replacing the habit of "mouse select → Command+C" with "mouse select → y". You only need to learn three keys: y / d / p, and once you're used to it, this is actually faster.

If You Really Want to Use Command+C: Modifier Key + Drag

If you don't want to switch to keyboard operations and want to stick with Command+C, holding a modifier key while dragging makes it a terminal-side selection, allowing you to copy with Command+C.

The modifier key varies by terminal app.

TerminalHow to Bypass Mouse Reporting
GhosttyShift+drag
iTerm2Shift+drag (Option+drag for rectangular selection)
Terminal.appfn+drag or Shift+drag (Option+drag for rectangular selection)

If You Want to Disable Mouse Operations Entirely: set mouse=

set mouse=

All mouse operations become the terminal's responsibility, so drag-to-select followed by Command+C works normally. However, you also lose the ability to position the cursor by clicking, which makes editing a bit less convenient.

Summary: Pasting from Mac Clipboard into Neovim

You can use whichever method fits the situation.

SituationHow to Do It
clipboard=unnamedplus configuredp in Normal mode
Not configured"+p in Normal mode
While in Insert modeCommand+V (via terminal paste function)

The Final init.vim

Putting all the settings together, here's what you get.

set mouse=nvi
set clipboard=unnamedplus
set number
syntax on
set autoread
au CursorHold,CursorHoldI * checktime
au FocusGained,BufEnter * checktime

Just seven lines, but this achieves the following.

  • Position the cursor by clicking with the mouse
  • Mouse drag to select → y to copy to the Mac clipboard
  • y / p / d are directly connected to the Mac clipboard
  • Command+V in Insert mode also works
  • External changes by Claude Code are automatically reloaded

Closing Thoughts

My conclusion is simple: bat if you just want to browse, Neovim if editing is also on the table. bat becomes immediately useful the moment you install it, and with just two lines in Neovim—set clipboard=unnamedplus and set autoread—you get a lightweight environment where you can read files with syntax highlighting and make edits when needed.

Neovim can be confusing at first due to the "mode" concept and the copy-and-paste philosophy, but once you get used to the idea that yank (y) and delete (d) directly become clipboard operations, there's a satisfying feeling of being able to complete your work without ever leaving the terminal.

For those moments when firing up an IDE feels like overkill but cat is too hard to read without syntax highlighting, using bat and Neovim in the right situations will make working with Claude Code significantly more comfortable. Give it a try.

Share this article