Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 266281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:50:31+00:00 2026-05-11T22:50:31+00:00

I want open a path to vim from Screen’s copy-mode by Ctrl-A f similarly

  • 0

I want open a path to vim from Screen’s copy-mode by

Ctrl-A f

similarly as I can open external files in Vim by

Ctrl-W f

How can you open a path in Vim in Screen’s copy-mode?


— Thank you for Samuil to get the crux move

Let’s assume mouse is at PATH/file in the following code which represents display when Screen is on

text[space]PATH/file[space]text

I press ^A f at PATH/file. It should save the PATH of the file to /tmp/screenCopyFile such that we can use cat in the following command which the ^A f should start:

^A: exec vim `cat PATH/file`

I run the command manually unsuccessfully. It did not expand the cat command, but it opens a file called cat.

In other words, we want to make the letter f stands for

exec vim `cat /tmp/screenCopyFile`

by binding in .screenrc.

Thank you Rampion for your answer!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T22:50:31+00:00Added an answer on May 11, 2026 at 10:50 pm

    Ok, here’s a solution:

    Put the following in /path/to/edit-file-under-cursor.screen:

    # edit-file-under-cursor.screen
    
    # prevent messages from slowing this down
    msgminwait 0
    # copy path starting at cursor
    stuff " Ebe "
    # write the path to a file
    writebuf /tmp/screen-copied-path
    # open that file in vim in a new screen window
    screen /bin/sh -c 'vim `cat /tmp/screen-copied-path`'
    # turn message waiting back on
    msgminwait 1
    
    # vi: ft=screen
    

    Then add this line to your .screenrc:

    # bind CTRL-f to open the file starting at the cursor
    # when in copy mode
    bindkey -m ^f source /path/to/edit-file-under-cursor.screen
    

    (changing the /path/to/ appropriately)

    Then, to use, make sure you restart screen (or reload the .screenrc).
    Enter copy mode with ^A[, cursor to the first character of a filename,
    then hit CTRL-f.

    I’ve tested this, and it works for me, so tell me if you have any issues.

    If you want to see how I knew how to do this, check man screen to
    see how all the various commands work.

    One improvement that could be made is to be able to find the beginning of a path, but I couldn’t do that reliably with only screen’s copy mode movement commands (e.g. anything that moved to the first / of “/a/path” moved to the | of “|/a/path“)

    This is due to the limitations of screen‘s movement commands in copy mode:

    Movement keys:
      h, j, k, l move the cursor line by line or column by column.
      0, ^ and $ move to the leftmost column, to the first or last non-whitespace character on the line.
      H, M and L move the cursor to the leftmost column of the top, center or bottom line of the window.
      + and - positions one line up and down.
      G moves to the specified absolute line (default: end of buffer).
      | moves to the specified absolute column.
      w, b, e move the cursor word by word.
      B, E move the cursor WORD by WORD (as in vi).
      C-u and C-d scroll the display up/down by the specified amount of lines while preserving the cursor position. (Default: half screen-full).
      C-b and C-f scroll the display up/down a full screen.
      g moves to the beginning of the buffer.
      % jumps to the specified percentage of the buffer.
    ...
    Searching:
      / Vi-like search forward.
      ? Vi-like search backward.
      C-a s Emacs style incremental search forward.
      C-r Emacs style reverse i-search.
    

    So if we changed the stuff line above to

    stuff "Bw Ebe "
    

    it would move to the start of a path, but it would also include any non-whitespace junk that came before the path. So as long as all your paths are whitespace delimited (on both sides) this should work.

    Actually

    stuff "B//^M E?/^Me "
    

    seems to work fairly well, since that uses searching to find the first and last / (type the ^M in vim by hitting CTRL-v, then enter). I haven’t tested all the edge cases, but it seems to work for:

     /a/path
     #/a/path
     /a/path#
    

    However, it’s going to fail for

     a/relative/path
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 253k
  • Answers 254k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It seems that there is no event I can subscribe… May 13, 2026 at 10:02 am
  • Editorial Team
    Editorial Team added an answer As you said, the name of a class is that… May 13, 2026 at 10:02 am
  • Editorial Team
    Editorial Team added an answer I was able to get a script to ignore extra… May 13, 2026 at 10:02 am

Related Questions

I want open a path to vim from Screen's copy-mode by Ctrl-A f similarly
I want to open a file in Vim like in Eclipse using Ctrl +
I want cscope to open files in MacVim instead of vim, so I'm trying
I am writing a Cocoa application with Mono embedded. I want to run and
As I open new tabs in vi/vim(7.2), if the opened files are in different

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.