1

Let's say we handle a file that needs various speciffic settings: We have a file type, syntax, colorscheme, highlights, tab widths and more. Also, we have multiple plugins with

Now, we want to derive another file from that, like extracting matching lines. The extracted lined share many properties with the original file, but not all: The syntax has possibly changed: Maybe there were no consecutive lines of the matched lines possible.

Let's say we handle a file that needs various speciffic settings: We have a file type, syntax, colorscheme, highlights, tab widths and more. Also, we have multiple plugins with file speciffic settings.

Now we derive a new file, say we extract matching lines. How can we transfer the settings from the old file to the new?

There may be two different cases to handle: in one case, the new file is created from the old one by a series of changes on a copy of the file content - the copy could possibly include the settings, so they can be just kept the same.

The other case is that the new file is created independently, like output of a shell command. Here, the settings really need to be copied over.

2
  • 1
    It's not really clear to me what exactly you're asking. Could you provide a simple example of what you've done, what happened, and what you would like to happen? This should probably make it clearer. Mar 1, 2015 at 2:53
  • I think all of the settings you're talking about are related to filetype. It's likely that by saving the new file with the right file extension, these settings would be applied. If you don't want to save the new file, you can try something like :setfiletype javascript.
    – tommcdo
    Mar 1, 2015 at 12:37

1 Answer 1

1

I do not completly understand what kind of problem you want to solve. But usually, if I want to keep all settings and variables attached to a single buffer, I use the :f <newfile> command to copy everything under a new file. Then you can remove all lines you do not need. Variables and settings however should remain as for the original buffer.

Is this what you are trying to achieve?

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