Intermediate
How to master Peek and Edit on Cursor
Quick Answer
Peek and Edit in Cursor allows you to view and modify code definitions without leaving your current context. This feature enables efficient code navigation and editing by opening inline windows that display referenced code.
Prerequisites
- Basic knowledge of code editors
- Familiarity with Cursor interface
- Understanding of code navigation concepts
- Knowledge of keyboard shortcuts
1
Enable Peek and Edit functionality
Open Cursor and navigate to Settings > Features. Ensure Peek Definition and Peek References are enabled. You can also access settings via
Ctrl+, on Windows/Linux or Cmd+, on Mac.Tip
Consider customizing keyboard shortcuts for peek commands in the Keyboard Shortcuts section for faster access.
2
Use Peek Definition to view code
Place your cursor on any function, variable, or class name in your code. Press
Alt+F12 (Windows/Linux) or Option+F12 (Mac) to open the peek definition window. The definition will appear in an inline editor below your current line without navigating away from your current file.Tip
You can also right-click and select 'Peek Definition' from the context menu.
3
Navigate within the peek window
Once the peek window is open, use the navigation controls at the top. Click the breadcrumb trail to see the file path, use arrow buttons to navigate between multiple definitions, or press
F12 to go to the actual definition file. The peek window shows line numbers and syntax highlighting.Tip
Use Ctrl+Click (Cmd+Click on Mac) on other symbols within the peek window to peek into their definitions recursively.
4
Edit code directly in peek window
Click inside the peek window to start editing the code directly. All changes are automatically saved to the original file. You can use standard editing shortcuts like
Ctrl+Z for undo, Ctrl+C/V for copy/paste, and Ctrl+F for find within the peek window.Tip
Changes made in peek windows are immediately reflected in the original file and any other open instances.
5
Use Peek References to see usage
Position your cursor on a function or variable and press
Shift+F12 to open peek references. This shows all locations where the symbol is used across your project. Navigate between references using the reference list on the left side of the peek window.Tip
The reference count is displayed at the top of the window - useful for understanding code impact before making changes.
6
Master peek window management
Close peek windows by pressing
Escape or clicking the X button. Resize peek windows by dragging the borders. You can have multiple peek windows open simultaneously by using peek commands on different symbols. Switch between peek windows using Tab when focused in a peek window.Tip
Use Ctrl+Shift+P (Cmd+Shift+P on Mac) and type 'peek' to see all available peek commands.
7
Customize peek behavior and appearance
Go to Settings > Editor > Peek Editor to customize peek window behavior. Adjust peek window height, enable/disable auto-focus, and configure peek border styles. You can also set whether peek windows should close automatically when clicking outside them.
Tip
Enable 'Editor: Peek Widget Default Focus' to automatically focus the peek editor for immediate typing.
Troubleshooting
Peek definition shows 'No definition found'
Ensure your language server is running properly. Check the Language Server Status in the status bar. Try restarting Cursor or running
Developer: Reload Window from the command palette.Peek window appears too small or cut off
Drag the peek window borders to resize, or go to Settings > Editor > Peek Editor and adjust the Default Height value. Try values between 12-20 for optimal viewing.
Keyboard shortcuts not working for peek commands
Check File > Preferences > Keyboard Shortcuts and search for 'peek'. Verify the shortcuts aren't conflicting with other extensions. Reset to default if needed.
Changes in peek window not saving
Ensure the file isn't read-only and you have write permissions. Check if the file is part of a version control system with locks. Try manually saving with
Ctrl+S while focused in the peek window.Ready to get started with Cursor?
Put this tutorial into practice. Visit Cursor and follow the steps above.
Visit Cursor →