What's the difference in perforce between a filetype of +S and +S1? - perforce

According to the Perforce documentation, setting a filetype of +S (with no number after it) indicates "only the head revision is stored".
Using a number, as in "+Sn", means "Only the most recent n revisions are stored, where n is a number from 1 to 10, or 16, 32, 64, 128, 256, or 512."
Does this mean that +S1 is identical to +S? Or does +S save only the head revision, and +S1 saves the head revision plus one more?

Empirically, it looks like +S is equivalent to +S1.
The p4v gui indicates this: when changing the filetype, the dropdown for "Server limits the number of revisions stored to:" maps "1" to +S, and "2" to +S2.
Also: If I manually change a filetype to +S1 using the command-line (p4 edit -t text+S1 RevisionsTest.txt), when viewed in p4v history, the +S1 becomes just +S.
Experiments with the behavior of the number of revisions stored seems to confirm that +S and +S1 are equivalent.

Related

How do I open files from my oldfiles list in vim?

In vim, I can type :oldfiles to see a list of files I've previously edited. Awesome feature!
But now I want to open one or more files from that list into a buffer. How can I do that?
Once you are at the bottom of the list you are supposed to press : and issue a command, using this "weird" notation:
:command #<91
where command could be any edit-like command (:edit, :tabedit, :split, :vsplit, :next, :args, etc.) and #< means "old file number…".
To edit entry 91, use:
:e #<91
To edit entries 18, 42 and 93, use:
:args #<18 #<42 #<93
If you use :help oldfiles, you will find the command :browse oldfiles which should do what you want.
:bro[wse] ol[dfiles][!]
List file names as with |:oldfiles|, and then prompt
for a number. When the number is valid that file from
the list is edited.
If you get the |press-enter| prompt you can press "q"
and still get the prompt to enter a file number.
Use ! to abandon a modified buffer. |abandon|
{not when compiled with tiny or small features}
Nearly 8 years later I stumbled on this old question and thought I'd update with what I do now (which is miles ahead of where this question ended).
I use fzf.vim and just type :History and then get an awesome fuzzy search over :oldfiles !

How to make vim indicate the file has changed since last save?

I used to work with netbeans and it always put an asterisk and changed the tab color when the file had changed since last save. Is there any way to make vim do something similar, that is, remind me that I haven't saved the file?
I know that there is a way to have it save automatically once in a while, but I don't want to do that.
You can use the m flag in the 'statusline' option to add a [+] if file is modified. Note that in order to see the statusline, you'll need to set 'laststatus' to be greater than 0 (1-Only shows status line if there are two or more windows, 2-Always).
If you're using a GUI-version, such as MacVim, you may prefer to set 'titlestring', which uses the same syntax but will alter the name of the window in your window-manager.
Example:
:set laststatus=2
:set statusline=[%n]\ %<%f%h%m
This will display:
[: literal
%n: buffer number
]: literal
\<Space>: a space
%<: Truncate the field at the beginning if too long
%f: Path to the file in the buffer, as typed or relative to current
directory.
%h: Help buffer flag, text is "[help]".
%m: Modified flag, text is "[+]"; "[-]" if 'modifiable' is off.
For more information see:
:help status-line
Call :ls and you will see a + before unsaved buffers
If the terminal displays its title somewhere, it's possible to use
:set title
to display whether the file is modified: a + is displayed after the file name if it's modified.
However, a file can have + at the end of its file name. For most files this should work fine.
Source: https://stackoverflow.com/a/13244715/5267751
Pressing Ctrl+g (or equivalently :f) in normal mode will show the file status, which indicates whether the file is modified.
The status looks like this
"file_name" 100 lines --20%--
if the file is not modified, or
"file_name" [Modified] 100 lines --20%--
if the file is modified.
For more info see :help ^g.

Relative line numbers from a fixed line

I'm using vim to manage a datafile that will be consumed by a program, and the format of the data file is as follows:
<Header line 1>
<Header line 2>
<Header line 3>
<Data line 1>
<Data line 2>
...
<Data line N>
With this format, which I cannot change, the data values don't start until line 4 in the file. The output from the program, however, refers to data values by number, which makes it difficult to quickly search through the file to find the right line. I experimented with vim 7.3+'s :set relativenumber (:set rnu) option, but it's designed to continuously update the base line used to calculate the relative line numbers.
I'm wondering if there's a way to fix the base line at line 3, so that lines 4, 5, and 6 will show up as lines 1, 2, and 3 (consistent with the program output). Any help would be appreciated!
UPDATE: What I ended up doing was adding this option manually in the source code. Very few changes were required; all I did was copy all of the code for :set relativenumber into a new option called :set fixednumber and then just disabled the section that automatically updates the line number when the row changes (this section is in the vim source file move.c). Now there are three mutually exclusive modes:
:set number -- normal line numbers
:set relativenumber -- automatically updating relative numbers
:set fixednumber -- relative line numbers that are fixed against the currently selected row when the option was set
No. The 0 in relativenumber is always the line on which your cursor is and the 1 in number is always line 1 of the buffer/file.
You could, however, open a new window with only the lines 4 -> N and work there.
Or add a +3 to each "jump to line n"…
With this mapping:
nnoremap <F9> :3+
you'd just need to hit <F9>, type the line number and hit <Enter>.
Vim is meant for editing text files as-is, so it'll require some contortions to make it suit your needs.
You can re-define the G command in your data file's buffers, like this:
:nnoremap <buffer> G :<C-u>execute (v:count ? v:count + 3 : line('$'))<CR>
The number column would be still off, though. To correct that, you'd have to remove the three initial header lines (maybe storing them in a buffer-local variable) when the buffer is loaded, and briefly re-insert them before the buffer is saved. This can be achieved with autocmds, but it's a little bit tricky to get right.
Another alternative is using a plugin like NarrowRegion, which opens a selected range in a scratch buffer, and synchronizes the contents back on save.

Vim: Only show “file has been changed” warning if content is different

Is it possible to setup Vim so that it will only show:
WARNING: The file has been changed since reading it!!!
If the file is actually different, not just when the timestamp changes?
For example, I'll quite frequently background Vim (^Z), roll back to an older version of a file (eg, to run the test suite against it), revert back to the current version and fg Vim again… But I still get the “file has changed” warning because, even though the content is identical, the timestamp has changed.
If you try on vim 7.3
:help timestamp
It is said that
When Vim notices the timestamp of a file has changed, and the file is being
edited in a buffer but has not changed, Vim checks if the contents of the file
is equal. This is done by reading the file again (into a hidden buffer, which
is immediately deleted again) and comparing the text. If the text is equal,
you will get no warning.
So I guess that in your case, something has changed other than the file timestamp ( or there is a bug in Vim).
In my case, I often get that message when I check out files : they change from "read only" to "read write" even if their content has not changed.
So I guess that if the properties of a file are affected, it is considered "changed" even if the content is the same.

Diff multiple files in perforce across a revision range

I'd like to diff a bunch of lines across several revisions. Like, I'd like to see a.c, b.c, and c.c from changelist X to changelist Y.
p4 diff2 a.c#X a.c#Y (where X & Y are changelist numbers) seems to work, but only sometimes. Specifically, if a.c is non-existent at X, I don't get a diff. I'd like to be able to get the diff (even though it'll be the whole file with only adds) anyways.
To get the bigger picture: I have several files, across several commits, and I'd like to merge the diffs of these files in these commits, to basically say "this is a diff of what changed in this set of files during this set of changelists"
If I understand your problem right, p4 diff -f ... should be your friend.
From the p4-help:
The -f flag forces a diff for every file, regardless of whether
they are opened or if the client has the named revision.
This can be used to verify the client contents.
(see p4 help diff on the command line).

Resources