To check how many PCIe lanes your NVMe drive is using in Windows use the following apps to get the information.
How to use:
Transfer Mode: PCIe 3.0 x4 | PCIe 3.0 x4
How to use:
The drive information in this tool is just information read from the tool, it does not have current lane, just information read from the firmware.
How to use:
Interface: PCIe Gen 4.0 x4
BOOTMGR
BOOTMGR
) is the bootloader provided by Microsoft for Windows NT versions starting with Windows Vista and Windows Server 2008. It is the first program launched by the BIOS or UEFI of the computer and is responsible for loading the rest of Windows. It replaced the NTLDR present in older versions of Windows.BOOTMGR
on either the system or the boot partition), accesses the Boot Configuration Data store and uses the information to load the operating system through winload.exe
or winresume.exe
on BIOS systems, and winload.efi
and winresume.efi
on UEFI systems.bootmgfw.efi
from an EFI system partition at startup, starting the Windows Boot Manager.BOOTMGR
/ VBR) from the active paritition.\windows\system32\winload.exe \windows\system32\boot\winload.exe
\EFI\Microsoft\Boot\bootmgfw.efi
\windows\system32\winload.efi \windows\system32\boot\winload.efi
Links
dd
..img
was not a format invented by dd, it’s just a raw image file — a byte-for-byte copy of a disk.There will be cross over between software functionality and their category.
VBoxManage convertfromraw source.img output.vdi --format VDI
qemu-img convert -f raw -O vhdx source.img output.vhdx
Convert-VHD –Path c:\VM\my-vhdx.vhdx –DestinationPath c:\New-VM\new-vhdx.vhdx –VHDType Dynamic
## Fixed --> Dynamic Convert-VHD -Path "D:\Path\To\Fixed-Disk.vhd" -DestinationPath "D:\Path\To\Dynamic-Disk.vhd" -VHDType Dynamic ## Dynamic --> Fixed (For Reference Only) Convert-VHD -Path "D:\Path\To\Disk-dynamic.vhd" -DestinationPath "D:\Path\To\Disk-trimmed-fixed.vhd" -VHDType Fixed
Optimize-VHD -Path "Path\To\Your\VHDfile.vhdx" -Mode Full
diskpart
elect vdisk file="<path>"
attach vdisk readonly
compact vdisk
detach vdisk
.vhd
as a .img
). .vhd
that was created by Rufus as a DD image.dd
(At least the Linux version of dd
doesn't care much if you try to write more data that the drive can hold - it'll report it, but it will not have any kind of impact on the data written), leaving you with a 1:1 copy of the original drive. .vhd
exactly as you would use a standard DD image. There REALLY is no "What if...?" or "But surely..." associated to using an uncompressed .vhd
as you would a DD image..vhdx
format. But:
Get-VHD -Path "C:\path\to\your.vhdx"
vhdxinfo mydisk.vhdx
type: fixed
or type: dynamic explicitly
.New-VHD -Path "C:\fixed-compliant.vhdx" -SizeBytes 10GB -Fixed
dd
or xcopy
to clone contents to the new disk.osfdisk
DAEMON Tools Lite: The most personal application for disc imaging yet - DAEMON-Tools.cc
select vdisk file=""
compact vdisk
Optimize-VHD -Path .ext4.vhdx full
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser iwr -useb https://raw.githubusercontent.com/okibcn/wslcompact/main/setup | iex
wslcompact -c ubuntu
Remove-Item "$($env:PSModulePath.split(';')[0])/WslCompact" -Recurse -Force
Open Powershell and run the following: wsl --shutdown diskpart select vdisk file="path-to-your-virtual-disk\ext4.vhdx" attach vdisk readonly compact vdisk detach vdisk exit
## Convert VBoxManage clonemedium disk --format VDI [drive]:[\path_to_file\sourceFile.vmdk] [drive]:[\path-to\destinationFile.vdi] ## Compact VBoxManage modifyhd --compact "[drive]:\[path_to_image_file]\[name_of_image_file].vdi"
VBoxManage modifyhd "[drive]:\[path_to_image_file]\[name_of_image_file].vdi" --resize 81920
VBoxManage internalcommands createrawvmdk
command in VirtualBox allows you to create a virtual disk that maps to a physical disk or partition. This is useful for accessing a physical disk directly from a virtual machine.VBoxManage internalcommands createrawvmdk -filename "C:\path\to\file.vmdk" -rawdisk \\.\PhysicalDrive0
.vmdk
file that represents the physical disk PhysicalDrive0
/dev/sda
on a Linux host:
VBoxManage internalcommands createrawvmdk -filename /path/to/file.vmdk -rawdisk /dev/sda -partitions 1,5
.vmdk
file that provides access to partitions 1 and 5 of /dev/sda
\\.\PhysicalDrive0
for Windows, /dev/sda
for Linux).VBoxManage internalcommands createrawvmdk
, you can effectively utilize physical disks within your VirtualBox VMs, providing flexibility and direct access to hardware resources.vboxManage internalcommands createrawvmdk -filename "C:\Users\Public\Documents\VirtualBox\Raw Disk Images\spinrite.vmdk" -rawdisk "\\.\PhysicalDrive2" vboxManage internalcommands createrawvmdk -filename "C:\rawdisks\spinrite.vmdk" -rawdisk "\\.\PhysicalDrive2"
Get-VHD -Path "C:\path\to\your.vhdx"
sudo apt install libvhdi-utils
brew install libvhdi
vhdxinfo yourfile.vhdx
00000000 76 68 64 78 66 69 6c 65 # "vhdxfile"
0x20000
, which lists metadata regions.Get-VM | Where { $\_.State -eq 'Off' } | Get-VMHardDiskDrive | Optimize-VHD -Mode Full
Instructions
VHD and VHDX are interchangeable for these commands.
Mount-VHD -Path "D:\Path\To\Fixed-Disk.vhdx" -ReadOnly Or Mount through the GUI (Disk Management, Right Click)
-ReadOnly
: This should protect the volume being written to by the OS, but not this command. I am not 100% on this.sdelete64.exe -z X:
X:
with the drive letter assigned to the mounted VHD.z
: This flag instructs ‘sdelete’ to write zeros over the available free space, a less intensive option than multiple passes and suitable for non-critical data.Dismount-VHD -Path "D:\Path\To\Fixed-Disk.vhdx" Or Unmount through the GUI (Disk Management, Right Click)
Convert-VHD -Path "D:\Path\To\Fixed-Disk.vhd" -DestinationPath "D:\Path\To\Dynamic-Disk.vhd" -VHDType Dynamic
Optimize-VHD -Path "D:\Path\To\Dynamic-Disk.vhdx" -Mode Full
diskpart select vdisk file="D:\Path\To\Dynamic-Disk.vhdx" attach vdisk readonly compact vdisk detach vdisk exit
readonly
: This should protect the volume being written to by the OS, but not this command. I am not 100% on this.Optimize-Volume -DriveLetter YourDriveLetter -ReTrim -Verbose Optimize-Volume -DriveLetter E -ReTrim -Verbose
## Check TRIM Timer/Schedule Status: sudo systemctl status fstrim.timer ## Check TRIM Service Status: sudo systemctl status fstrim If TRIM is enabled, an operation will run at the next scheduled time. If TRIM is not enabled, you can ## Run a manual TRIM using: sudo fstrim -av ## Info It is recommended to enable automatic TRIM to ensure that data usage is reflected accurately between VergeOS and the guest OS. ## To enable automatic TRIM, run: sudo systemctl enable fstrim.timer
Is htis best ehre or antoher article
TL;DR = Might not be possible any more, and if it is, it is not worth the hassle.
My DiskGenius Notes
To boot DiskGenius from Ventoy, we need to generate the WinPE Bootable USB Drive and image it. Ventoy allows the use of several different image formats, all with their own strengths.
Create WinPE Bootable USB Drive - DiskGenius - DiskGenius supports to make bootable USB disk based on Windows PE so that you can recover lost data, manage disk or backup data when system cannot boot.
- When you create your USB drive I think the build process uses your PC for the drivers and WinPE files so the resulting data size on the USB drive will change depending on your system.
- I don't know if the DiskGenius USB drives are tried to the PC they were created on.
Format the USB drive
Although DiskGenius can use a USB drive in either the "Supper Floppy" (FDD) or Hard drive mode (HDD) it is easier to work with a HDD version where it has an MBR and Partition table like a traditional hard drive.
When you format a USB drive in Windows the "Super Floppy" format is used by default. I am not sure what happens when you use Windows to format a USB drive taht has a partition table, perhaps ot leaves it alone.
Non bootable
MBR
BIOS or UEFI
DISKGENIUS
(or whatever you want)FAT32
Default
(this might vary depending on the size of the USB drive)
- I would recommend getting a 2GB USB drive to keep the image size down and reduce the number of steps required.
- (Win10 WinPE = 550mb)
- (Win11 WinPe = 1GB+)
- The size difference between the images created by these formats is minimal.
FIXEDSIZE-DiskGenius v6.0.1.1645.vhdx
sdelete
to zero out unused space on the USB drive's volumeDiskGenius v6.0.1.1645.vhdx
DiskGenius v6.0.1.1645.vhdx
to your ventoy images partition.diskmgmt.msc
C:\Users\quantunwarp\Desktop\DiskGenius v6.0.1.1645.vhdxDiskGenius v6.0.1.1645.vhdx
2GB
VHDX
Dynamically expanding (Recommended)
Initialise Disk
MBR
partition styleFAT32
Default
Disk Genius
DiskGenius v6.0.1.1645.vhdx
to your ventoy images partition.
- This only works for UEFI/EFI environments.
- If you try and boot the WIM when using MBR/CSM/Legacy it will start to load and then a black screen will overlay the Ventoy loader and it will crash.
...\DiskGenius - Boot\boot.wim
boot.wim
to something human readable like DiskGenius v6.0.1.1645.wim
DiskGenius v6.0.1.1645.vhdx
to your ventoy images partition.
- This is a very trick and time consuming option and is not really needed
- Try and find and ISO already done, and then use this.
method 1 get a windows disk and swap out the contents, keeping the boot sector
DiskGenius v6.0.1.1645.iso
to your ventoy images partition.
select vdisk file="<PathToYourDesktop>\DiskGenius v6.0.1.1645.vhdx"
<PathToYourDesktop>\DiskGenius v6.0.1.1645.vhdx
- TL;DR this error is caused by the source USB formatted as a "Super Floppy"
- Starwind P2V does not support "Super Floppy" for live copying as it expects a partition table.
- A USB drive can be formatted as a traditional hard drive (HDD) or in a "Super Floppy" format akin to a traditional floppy disk (FDD).
- "Super Floppy" does not have a MBR or a Partition Table which is what Starwind is looking for when copying from the mounted Disk image.
- Starwind wiil not present/see Removable Media disks or their Volumes only hard disks.
Scenario
Log File
7/21 16:24:49.493 2b68 Facility ???INFO: CV2V_ConverterApp::InitInstance: SetDllDirectory: C:\Program Files\StarWind V2V Converter\lib 7/21 16:24:49.493 2b68 Facility ???INFO: CV2V_ConverterApp::InitInstance: File Version: 9.0.1.757 7/21 16:24:49.508 2b68 Facility ???INFO: CV2V_ConverterApp::InitInstance: Load language IDR_XML_ENGLISH 7/21 16:24:49.508 2b68 Facility ???INFO: CV2V_ConverterApp::InitInstance: Set current language English 7/21 16:24:49.508 2b68 Facility ???INFO: CPS_V2V_Converter::CPS_V2V_Converter: Version MajorVersion 10, MinorVersion 0, BuildNumber 19045 7/21 16:24:49.508 2b68 Facility ???INFO: WrapperHyperV::WrapperHyperV: LoadLibrary C:\Windows\system32\wbem\wmiutils.dll - 94cb0000 7/21 16:24:49.508 2b68 Facility ???INFO: WrapperHyperV::WrapperHyperV: LoadLibrary C:\Windows\system32\wbem\wmiutils.dll - 94cb0000 7/21 16:24:53.723 2b68 Facility ???INFO: ICPPage::OnWizardNext: SetActivePage - eSynchronization 7/21 16:24:57.926 2b68 Facility ???INFO: ICPPage::OnWizardNext: SetActivePage - eAzureConnectionTo 7/21 16:25:06.162 2b68 Facility ???INFO: ICPPage::OnWizardNext: SetActivePage - eLocationTo 7/21 16:25:09.053 2b68 Facility ???INFO: ICPPage::OnWizardNext: SetActivePage - eFormat 7/21 16:25:12.381 2b68 Facility ???INFO: ICPPage::OnWizardNext: SetActivePage - eOptionsHyperV 7/21 16:25:17.914 2b68 Facility ???INFO: ICPPage::OnWizardNext: SetActivePage - eConverting 7/21 16:25:43.043 2b68 Facility ???INFO: CPPOutputFile::onNext: Out path: C:\Users\quantumwarp\Desktop\DiskGenius-Dynamic.vhdx, Out format 11 7/21 16:25:43.043 2b68 Facility ???INFO: ICPPage::OnWizardNext: SetActivePage - eHYPERVConnectionTo 7/21 16:25:43.043 1788 Facility ???INFO: CPPConverting::Convert: InConvertType: 2, OutConvertType: 4 7/21 16:25:43.043 1788 Facility ???INFO: CPPConverting::ConvertDisks: pathInput: 1, pathOutput: C:\Users\quantumwarp\Desktop\DiskGenius-Dynamic.vhdx 7/21 16:25:43.043 1788 Facility ???INFO: P2V::CreateInputImage: path 1 7/21 16:25:43.043 1788 Facility ???INFO: P2V::CreateInputImage: Size 1 - 15518924800, BytesPerSector - 512 7/21 16:25:48.090 1788 Facility ???INFO: CPPConverting::ConvertDisks: CreateInputImage: 0 7/21 16:25:48.090 1788 Facility ???INFO: CPPConverting::ConvertDisks: CreateOutputImage: 0 7/21 16:25:48.090 1788 Facility ???ERROR: CPPConverting::ConvertImage: Read 3 7/21 16:32:00.054 1788 Facility ???ERROR: CPPConverting::ConvertDisks: ConvertImage - 2 7/21 16:32:00.054 1788 Facility ???ERROR: CPPConverting::Convert: FAILED
Log Explained
Here's what the log tells us:
9.0.1.757
- This is a relatively recent version, so it's unlikely to be a bug in an old release.InConvertType: 2
- This indicates a Physical Disk source.OutConvertType: 4
- This indicates a Hyper-V (VHDX) destination.pathInput: 1
and Size 1 - 15518924800, BytesPerSector - 512
pathInput: 1
likely refers to the "Disk 1" as seen by Windows Disk Management. This corresponds to the virtual disk presented by OSFMount.15,518,924,800 bytes
(approx 14.45 GB) and BytesPerSector - 512
are correctly identified by the converter from the virtual disk.CPPConverting::ConvertDisks: CreateInputImage: 0
- This line means StarWind successfully initialized the connection to the source disk.CPPConverting::ConvertDisks: CreateOutputImage: 0
- This line means StarWind successfully initialized the connection to the destination VHDX file.CPPConverting::ConvertImage: Read 3
- This is the critical error. It happens immediately after the input and output images are created, right at the point where StarWind tries to read the actual data from the source disk. This confirms a low-level read error from the OSFMounted virtual disk.ConvertImage - 2, FAILED
) are a direct consequence of this initial read failure.10/21 12:55:57.929 2764 Facility ???WARNING: P2V::getBuffer: ReadFile - 23. Data error (cyclic redundancy check). 10/21 12:55:57.929 2764 Facility ???ERROR: CPPConverting::ConvertImage: Read 3 10/21 13:03:16.650 2764 Facility ???ERROR: CPPConverting::Convert: FAILED
After in-depth research I can clarify the error is not cause by:
boot.wim
there is no difference (Win10 = 550mb)(Win11 = 1GB).What I have tried
There are a couple of methods outlined below.
diskpart list disk select disk # detail disk
Microsoft DiskPart version 10.0.26100.1150 Copyright (C) Microsoft Corporation. On computer: WIN11PC DISKPART> list disk Disk ### Status Size Free Dyn Gpt -------- ------------- ------- ------- --- --- Disk 0 Online 1863 GB 4096 KB * Disk 1 Online 7651 MB 0 B DISKPART> select disk 1 Disk 1 is now the selected disk. DISKPART> detail disk General USB Flash Disk USB Device Disk ID: 6F20736B Type : USB Status : Online Path : 0 Target : 0 LUN ID : 0 Location Path : UNAVAILABLE Current Read-only State : No Read-only : No Boot Disk : No Pagefile Disk : No Hibernation File Disk : No Crashdump Disk : No Clustered Disk : No Volume ### Ltr Label Fs Type Size Status Info ---------- --- ----------- ----- ---------- ------- --------- -------- Volume 5 E PICTURES FAT32 Removable 7651 MB Healthy DISKPART> list partition Partition ### Type Size Offset ------------- ---------------- ------- ------- * Partition 1 Primary 14 GB 0 B DISKPART> select partition 1 There is no partition selected. DISKPART>
There is no partition selected.
, indicating it has an error accessing the partition table, which do not exist on "Super Floppy" USB drives.
- Always use Dynamic/Growable disk image files where possible to keep space used down.
- Always use MBR/HDD style formatting on your USB drives where possible.
A
.
- TL;DR = UEFI GOP (Graphics Output Protocol) sets the screen resolution before WinPE when using EFI on my lenovo (resolution seems to be set at 800x600 and cannot be changed)
- Solution = Boot in legacy mode and then change the resolution in DiskGenius if needed: View --> Set screen resolution (Options: 1920x1080, 1024x768). This was on my Lenovo laptop.
- Notes
- Using a different boot loader like Grub which can be used to see what resolutions the GOP provides.
- My Lenovo on EFI returns a resolution of 800x600 but when I use CSM/Legacy I get 1024x768 and 1920x1080 which I can swap between with the DiskGenius menu in WinPE.
- For most users on modern UEFI systems — the hard limit is 1024x768.
- Some people say showing the boot logo helps increase screen resolution (not tested).
When trying to change the resolution of my screen when using DiskGenius on my Lenonvo latop.
<?xml version="1.0" encoding="utf-8"?> <unattend xmlns="urn:schemas-microsoft-com:unattend"> <settings pass="windowsPE"> <component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Display> <ColorDepth>32</ColorDepth> <HorizontalResolution>1920</HorizontalResolution> <RefreshRate>60</RefreshRate> <VerticalResolution>1080</VerticalResolution> </Display> </component> </settings> </unattend>
X:\bcdedit /store D:\boot\BCD /set {globalsettings} graphicsresolution 1280x1024
bcdedit /store "d:\boot\BCD" /set {bootmgr} graphicsresolution "800x600" bcdedit /store "d:\boot\BCD" /set {bootmgr} graphicsresolution "1024x768"
bcdedit /store "d:\boot\BCD" /set {bootmgr} graphicsresolution "1280x768" bcdedit /store "d:\boot\BCD" /set {bootmgr} graphicsresolution "1280x1024"
graphicsresolution
is backed by the boot graphics adapter using VESA BIOS Extensions (VBE) or UEFI GOP (Graphics Output Protocol).
bcdedit.exe /set {globalsettings} graphicsresolution 800x600 bcdedit.exe /set {globalsettings} graphicsresolution 1024x600 bcdedit.exe /set {globalsettings} graphicsresolution 1024x768
C:\windows\system32>bcdedit.exe /set {globalsettings} graphicsresolution 1920x1080 The integer data is not valid as specified. Run "bcdedit /?" for command line assistance. The parameter is incorrect.
bcdedit.exe /set {globalsettings} highestmode on
graphicsmode --info
command on the GRUB4UEFI commandline. QRes.exe /x:800 /y:600
nircmd.exe setdisplay 1024 768 24
This is just a temporary article for these notes, I might move them.
/var/lib/mysql/server.quantumwarp.com.err
^(?!.*\[ERROR\] mariadbd: Table).*\r?\n
.*\[ERROR\] mariadbd: Table '\.
' is marked as crashed and should be repaired$
Throughout these examples I have used the regex
YourCodeHere
to and you should change this to match your needs
Find: ^.*YourCodeHere(.*) Replace: YourCodeHere\1
$
your content
Notes
A couple of methods to identify lines and delete them.
.*YourCodeHere.*\n .*YourCodeHere.*\r?\n
Notes
\n
if straight from your Linux box, but you might just want to check this as it could be \r\n
YourCodeHere
should be swapped for something on each of the lines you want to delete.A couple of methods to identify lines and delete all the others.
^(?!.*YourCodeHere).*\r?\n ^(?!.*YourCodeHere).*\R # When this is used, blank lines are left ^((?!YourCodeHere).)*$
YourCodeHere # This will allow marking of all lines not containing [ERROR] ^((?!YourCodeHere).)*$
Find: ^.*YourCodeHere Replace: YourCodeHere or Find: ^.*?YourCodeHere Replace: YourCodeHere
A collection of hints and tips of this topic.
Notepad++ supports showing newlines as CR/LF/CRLF
but does not support showing newlines as ↵
, however you can simulate it:
?
operator after a quantifier.a[^c]+c
a
, followed by one or more character that isn't c
, followed by c
. This will match abc
and adc
.Now Notepad++ will recognise .tpl files as PHP files. When you open the next one, it will contain syntax highlighting.
- I am using the Fira Code here for this example but this will apply to all fonts where this occurs
- The EOL character is shown when using the DejaVu Mono font.
- The question mark character is shown is when the required glyph does not exist in the current font.
- When copying text, the glyph references are copied not the characters, so if a character does not show correctly in one application this does not mean this will be the same in another.
The issue you're encountering is due to the Fira Code font not supporting the ↵
character (Unicode U+21B5: "DOWNWARDS ARROW WITH CORNER LEFTWARDS").
!=
into a neat symbol), but it has a more limited set of Unicode glyphs compared to DejaVu Mono.↵
, so Notepad++ shows a replacement character (typically a question mark or a box), indicating a missing glyph.↩
, ↓
, or ⏎
), though it’s not the same.You can test if Fira Code supports a character by:
VS Code and Notepad++ handle fonts very differently, particularly when it comes to missing glyphs:
App | Font Used | ↵ Glyph Supported by Font? | Font Fallback? | Result |
---|---|---|---|---|
VS Code | Fira Code | ❌ | ✅ Yes | ✔️ Displays ↵ |
Notepad++ | Fira Code | ❌ | ❌ No | ❌ Question mark |
Window should just enable this by default but it doesn't even in windows 11.
The tutorials in the links below will give you a clearer understanding of how and why to perform this upgrade but this is an overview of the methods I found
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -Name LongPathsEnabled -Type DWord -Value 1
Computer Configuration > Administrative Templates > System > Filesystem > Enable Win32 long paths
LongPathsEnabled
is enabledSet-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -Name LongPathsEnabled -Type DWord -Value 1
Computer Configuration > Administrative Templates > System > Filesystem > Enable win32 long paths
LongPathsEnabled
setting on all Windows servers hosting Veeam roles.dddd
So you are installing `Git for Windows` and you are asked how to handle line endings, what option should I pick and why? I will answer this question here so you know what to choose and why rather than just following a YouTube video than never explains anything except just click next because this is what I use.
The information here applies to handling EOL in Git and probably applies to people whoe's OS is not Windows such as MacOS and Linux.
Where I can change line endings when using Git for Windows and VSCode? (each overrides the last)
Settings precedence - User and workspace settings | Visual Studio Code
- VSCode (User settings) (
%APPDATA%\Code\User\settings.json
)
- Action: Set EOL for new files.
- Scope: All Workspaces.
- Additional:
- Command Palette ( F1 | Ctrl+Shift+P) --> Preferences: Open User Settings --> `Files: Eol`: LF
- Settings --> Text Editor --> Files --> Eol: LF
- Profiles replace the `User settings`, if loaded.
- These settings are only per user which means they are local and are not shared.
- VSCode (Workspace settings) (
.vscode/settings.json
)
- Action: Set EOL for new files.
- Scope: Workspace.
- Additional:
- These settings can be commited to a repo and thus can be shared between colleagues and the wider world.
- VSCode (Multi-Root Workspace / Workspace Folder setting) (
.vscode/.code-workspace
)
- Action: Set EOL for new files.
- Scope: Specified Workspace Folders.
- Additional:
- Settings for a particular folder can be saved in the
.code-workspace
.- These settings can be commited to a repo and thus can be shared.
- VSCode (Multi-Root Workspace) (
[Workspace Folder]/.vscode/settings.json
)
- Action: Set EOL for new files.
- Scope: Workspace Folder
- Additional:
- These settings can be commited to a repo and thus can be shared.
- Git (Repository) (
.editorconfig
)
- Action: Set EOL for new files.
- Scope: Git repository.
- Additional:
- Visual Studio = Full native support, VS will check your code on every code change.
- VSCode = Partial support is added by extensions.
- VSCode (Extensions) - Examples below:
- Auto Convert End Of Line - Visual Studio Marketplace
- Action: Change the EOL for all
text
files, on save- Scope: Workspace
- Prettier - Code formatter - Visual Studio Marketplace
- Action: Change the EOL for all files, as specified (see below) on save
- Scope: Workspace
- Additional:
- You can use VS Code settings to configure prettier. Settings will be read from (listed by priority):
.prettierrc
(Prettier configuration file).editorconfig
- Visual Studio Code Settings (Ignored if any other configuration is present)
- NOTE: If any local configuration file is present (i.e.
.prettierrc
) the VS Code settings will NOT be used.- The VS Code settings are meant to be used as a fallback and are generally intended only for use on non-project files.
- It is recommended that you always include a prettier configuration file in your project specifying all settings for your project.
- If
options.editorconfig
istrue
and an.editorconfig
file is in your project, Prettier will parse it and convert its properties to the corresponding Prettier configuration. This configuration will be overridden by.prettierrc
, etc. Currently, the following EditorConfig properties are supported:
end_of_line
indent_style
indent_size
tab_width
max_line_length
- End of Line - Options · Prettier - Prettier ships with a handful of format options.
- Unlocking Prettier: Mastering End of Line Configuration | runebook.dev
- Inconsistent EOL characters can lead to unnecessary Git conflicts, making it harder to track changes and collaborate effectively.
- Prettier aims to enforce consistent code style across a project or team. This includes standardizing how line endings are represented.
- This article covers
.prettierrc
and.gtiattributes
- ESLint - Linter - Visual Studio Marketplace
Action: Change the EOL for all files, as specified (see below) on save
Scope: Workspace
- EditorConfig for VS Code - Visual Studio Marketplace
- Action: Change the EOL for all files, as specified in
.editorconfig
, on save- Scope: Workspace
- Additional:
- Supported Properties
indent_style
indent_size
tab_width
end_of_line
(on save)insert_final_newline
(on save)trim_trailing_whitespace
(on save)- Git (Repository) (
.gitattributes
)
- Action: Change the EOL for all files
- Scope: Git repository, but only on files as specified in the
.gitattributes
- Additional:
- Applied when files are checked-in (submitted) to this Git repo.
- Git (Global Config / Git for Windows) (
.gitconfig
)
- Action: Change the EOL for all files
- Scope: All local Git repositories.
- Additional:
- Occurs when files are submitted or retrieved from any Git repo.
- Only
core.autocrf=true
performs a conversion on EOLs during on Check-in and Checkout, all other settings are Checkin-in only.
How to enforce LF EOL (Windows --> VSCode --> Git)
Making the following changes to your Editor and Repo will ensure the best outcome
- VSCode (User settings) (
%APPDATA%\Code\User\settings.json
)
- Scope:
- Set EOL LF for new files, for the User.
- Actions:
- Enable
LF
as the defaultEOL
for the current VSCode User
- Command Palette --> Preferences: Open User Settings --> `file end of line` --> `Files: Eol`: \n
- It will indicate LF at the bottom of the dropdown, which is fine as this is is just a note.
- VSCode (Workspace settings) (
.vscode/settings.json
)
- Scope:
- Set EOL LF for new files, for the Workspace.
- Actions:
- Enable
LF
as the defaultEOL
for the VSCode Workspace
.vscode/settings.json
{ "files.eol": "\n" }Command Palette --> Preferences: Open Workspace Settings --> `file end of line` --> `Files: Eol`: \n
- Git (Repository) (
.editorconfig
)
- Scope:
- Set EOL LF for new files, for the Git Repository.
- Some VSCode extensions will use the EOL and apply upon save.
- Actions:
- Enable
.editorconfig
support (Visual Studio does not need this)
- Install EditorConfig for VS Code
- Not required if you use Prettier as this has supports, but you will need to make sure it is configured to respect
.editorconfig
however.prettierrc
settings will always override.editorconfig
values..editorconfig
sets the EOL for new files but these VSCode extensions set the EOL on save.- Create
.editorconfig
# EditorConfig is awesome: https://EditorConfig.org # top-most EditorConfig file root = true # Default Behaviour [*] end_of_line = lf- VScode (Extensions) (
.prettierrc
) (Prettier)
- Scope:
- Can use .editorconfig or it's own settings, Set EOL LF for new files, for the Git Repository.
- Some VSCode extensions will use the EOL and apply upon save.
- Actions:
- Create
.prettierrc
(only needed if using Prettier){ "endOfLine": "lf" }- VScode (Extensions) (
eslint.config.js
) (ESLint)
- SCope
- Can use .editorconfig or it's own settings, Set EOL LF for new files, for the Git Repository.
- Some VSCode extensions will use the EOL and apply upon save.
- Actions:
- Create
eslint.config.js
(only needed if using ESLint)import { defineConfig } from "eslint/config"; export default defineConfig([ // Default Line Ending { files: ['**/*.*'], rules: { 'linebreak-style': ['error', 'unix'], }, }, // Force batch scripts to always use CRLF line endings { files: ['**/*.[bB][aA][tT]', '**/*.[cC][mM][dD]'], rules: { 'linebreak-style': ['error', 'windows'], }, }, // Force bash scripts to always use LF line endings { files: ['**/*.sh'], rules: { 'linebreak-style': ['error', 'unix'], }, }, ]);- Git (Repository) (
.gitattributes
)
- Scope
- Enforce conversion of EOL to LF.
- Actions:
- Create
.gitattributes
(optional)
# Default Line Ending * text=auto eol=lf
- This will change all text file's EOL to LF when checking them into the repository, but not when you check them out in to your working tree (i.e. real files).
- This is a fallback to enforce EOL before committing and should not be needed if everything in your repo is setup correctly.
- Using this setting (* text=auto eol=lf) on it's own can cause corruption in some case, so a more granular .gitattributes configuration should be usedas Git can make mistakes with line endings, e.g. mixed EOL files and those with binary blobs
- Use and this is a base reference and also consult further notes on this page.
* text=auto eol=lf
is the same as* text=auto
- This rule is doing the same for this repository as
core.autocrf=input
would do for the whole local Git instance.
EOL Handling Summary
- General
- DO NOT use
core.autocrlf
to normalise your line endings
- This can lead to file corruption (i.e. embedded binary blobs in a text file)
- You cannot assume everyone has set their Git development environment the same.
- These settings would be global and thus a local repository would not have control and nor could you mandate changes with your editor.
- Use
.gitattributes
and.editorconfig
to configure line normalisation
- These work on a Per-Repository basis.
- This will allow you granular control of EOL.
- Supports files with different EOL.
- Support an individual file with mixed EOL.
- The repository can define the EOL handling rather than individual user environments.
- This is the professional way to setup a repository.
- .git
- Repo (check-in) = Commit = Submitted to Git
- Working Tree (checkout) = The real files on your PC
- .gitconfig
core.autocrlf=true
- Converts text file's EOL to
LF
on check-in to the repo from the working tree.- Converts text file's EOL to
CRLF
on checkout from the repo to the working tree.- Tends to be recommended setting for Windows developers since it guarantees
LF
in the remote copy of your code while allowing you to useCRLF
in your working tree for full compatibility with Windows editors and file formats.- This setting only needs be used in a Window environment
, but can work in other OS.
core.autocrlf=input
- Converts text file's EOL to
LF
on check-in to the repo from the working tree.- Leaves the working tree untouched.
- This would be the same as:
* text=auto eol=lf
and* text=auto
, but applied globally.- .gitattributes
- Controls how EOL are handled when checking-in files to the Git repository.
- Local files (Working Tree) and their EOL are unaltered by these settings.
- Conflicts might occur when checking out files, but these can be resolved locally without poisoning the repo.
* text=auto eol=lf
,* text=auto
andcore.autocrlf=input
all do the same thing exceptcore.autocrlf=input
works at the Git server level and not on a per repository basis.- (untested) This file will override the
core.autocrlf
settings for specified files in this repository if an appropriate rule exists.- Using this file ensures a consistent behavior for all users, regardless of their Git settings and environment.
- .editorconfig
- An open, editor agnostic schema.
- Defines the EOL for all new files.
- Some VSCode extensions use these settings on save, so these settings can work on new and created files.
- VSCode (User Settings)
- Configuring EOL here will only apply to new files.
- You should change the default EOL to LF as a fallback precaution (unless you are working on Windows only environment).
- These settings are only per user which means they are local and are not shared.
- VSCode (Workspace settings)
- Configuring EOL here will only apply to new files.
- You should change the default EOL to LF as a fallback precaution (unless you are working on Windows only environment).
- These settings can be commited to a repo and thus can be shared.
Checkout as-is, commit as-is (Git for Windows) (core.autocrlf = false)
Why should I choose this option, here is a simple Pros vs Cons:
.gitattributes
..editorconfig
will be honoured and kept when the files are submitted to the repository.Checkout Windows-style, commit Unix-style line endings (Git for Windows) (core.autocrlf = true)
Why should I choose this option, here is a simple Pros vs Cons:
So you already have a load of files with CRLF
and now you need them all to be LF
before committing them to Git.
find . -type f -exec dos2unix {} \;
TYPE input_filename | MORE /P > output_filename
sed -i 's/$/\r/' fileLinux.txt find -type f -exec sed -i 's/$/\r/' '{}' \; tr -d '\r' < fileWindows.txt > fileLinux.txt sed -i 's/\r//' fileWindows.txt
## To convert the newline characters from DOS/Windows to Unix/Linux: $ dos2unix <filename> ## To convert the newline characters from Unix/Linux to DOS/Windows: $ unix2dos <filename>
npm i -g eol-converter-cli eolConverter crlf "**/*.{txt,js,java,etc}"
# Set the default behavior, in case people don't have core.autocrlf set. * text=auto # Explicitly declare text files you want to always be normalized and converted # to native line endings on checkout. *.c text *.h text # Declare files that will always have CRLF line endings on checkout. *.sln text eol=crlf # Denote all files that are truly binary and should not be modified. *.png binary *.jpg binary
git config --global core.autocrlf inputThis will fix any
CRLF
to LF
when you commit.git config --global core.autocrlf trueThis will make sure that, when you checkout in windows, all
LF
will be converted to CRLF
..gitattributes
file as we don't want to expect everyone in our team to set their own config. This file should be placed in the repository root and, if it exists, git will respect it.## Specify precise line ending behaviors * text=auto *.sh text eol=lf *.bat text eol=crlf *.txt text eol=lf
.gitattributes
file* -text
in the .gitattributes
and add .editorconfig
that enforces the projects preferred line endings. An added benefit is that you can also specify file encodings in your .editorconfig
file.############################### # Git Line Endings # ############################### # Set default behaviour to automatically normalize line endings. * text=auto # Force batch scripts to always use CRLF line endings so that if a repo is accessed # in Windows via a file share from Linux, the scripts will work. *.{cmd,[cC][mM][dD]} text eol=crlf *.{bat,[bB][aA][tT]} text eol=crlf # Force bash scripts to always use LF line endings so that if a repo is accessed # in Unix via a file share from Windows, the scripts will work. *.sh text eol=lf ############################### # Git Large File System (LFS) # ############################### # Archives *.7z filter=lfs diff=lfs merge=lfs -text *.br filter=lfs diff=lfs merge=lfs -text *.gz filter=lfs diff=lfs merge=lfs -text *.tar filter=lfs diff=lfs merge=lfs -text *.zip filter=lfs diff=lfs merge=lfs -text # Documents *.pdf filter=lfs diff=lfs merge=lfs -text # Images *.gif filter=lfs diff=lfs merge=lfs -text *.ico filter=lfs diff=lfs merge=lfs -text *.jpg filter=lfs diff=lfs merge=lfs -text *.pdf filter=lfs diff=lfs merge=lfs -text *.png filter=lfs diff=lfs merge=lfs -text *.psd filter=lfs diff=lfs merge=lfs -text *.webp filter=lfs diff=lfs merge=lfs -text # Fonts *.woff2 filter=lfs diff=lfs merge=lfs -text # Other *.exe filter=lfs diff=lfs merge=lfs -text
.gitattributes
. git status
tells you that you’ve changed a file, but running git diff
doesn’t show you any changes.core.autocrlf
is enabled, Git will convert CRLF to LF during commit and LF to CRLF during checkout. A file that contains a mixture of LF and CRLF before the commit cannot be recreated by Git. For text files this is the right thing to do: it corrects line endings such that we have only LF line endings in the repository. But for binary files that are accidentally classified as text the conversion can corrupt data.core.safecrlf
is basically just a way to make sure you don’t irreversably perform CRLF conversion on a binary file..gitattributes
file to manage how Git reads line endings in a specific repository. When you commit this file to a repository, it overrides the core.autocrlf
setting for all repository contributors. This ensures consistent behavior for all users, regardless of their Git settings and environment.lf
, crlf
and native
, which uses the platform’s native line ending. The default value is native
.
git config core.eol lf # LF git config core.eol crlf # CRLF git config core.eol native # platform (default)
# Set the default behavior, in case people don't have core.autocrlf set. * text=auto # Explicitly declare text files you want to always be normalized and converted # to native line endings on checkout. *.c text *.h text # Declare files that will always have CRLF line endings on checkout. *.sln text eol=crlf # Denote all files that are truly binary and should not be modified. *.png binary *.jpg binary
core.autocrlf
setting isn’t the ideal approach for configuring line endings in a project..gitattributes
file to your repo so you can enforce line endings consistently in your codebase regardless of what operating systems your developers are using..gitattributes
file is technically all that you need to enforce the line endings in the remote copy of your code. However, as we just saw, you may still see CRLF
line endings on Windows locally because .gitattributes
doesn’t tell Git to change the working copies of your files. Fortunately, we can take things a step further with an .editorconfig
file; this is an editor-agnostic project that aims to create a standardized format for customizing the behavior of any given text editor. Lots of text editors (including VS Code) support and automatically read this file if it’s present.core.autocrlf
is set to false
on a fresh install of Git, meaning Git won’t perform any line ending normalization. Instead, Git will defer to the core.eol
setting to decide what line endings should be used; core.eol
defaults to native
, which means it depends on the OS you’re using. That’s not ideal because it means that CRLF
may make its way into your code base from Windows devs.core.autocrlf=true
converts files to CRLF
on checkout from the repo to the working tree, while core.autocrlf=input
leaves the working tree untouched.core.autocrlf=true
tends to be recommended setting for Windows developers since it guarantees LF
in the remote copy of your code while allowing you to use CRLF
in your working tree for full compatibility with Windows editors and file formats..gitattributes
config normalizes line endings to LF
for all text files checked into your repo while leaving local line endings untouched in the working tree:text=auto
option tells Git to only normalize line endings to LF
for text files while leaving binary files (images, fonts, etc.) untouched. This distinction is important—we don’t want to corrupt binary files by modifying their line endings..gitattributes
file, your changes won’t take effect immediately for files checked into Git prior to the addition of .gitattributes
. To force an update, you can use the following command since Git 2.16:CRLF
) for line endings, operating systems like Linux and Mac use only the line feed (LF
) character..gitattributes
file to normalize your line endings regardless of what operating systems your developers are using..editorconfig
file to ensure that new files are always created with LF
line endings, even on Windows..gitattributes
file is indeed the best practice, but if you are working on a personal repository, it shouldn’t matter. In fact, autocrlf=true
wouldn’t cause any problems even if you were working with other Linux/Mac developers since the remote code would always have LF
line endings anyway. The main reason why autocrlf
is not useful is because you have to keep setting it up every time you get a new Windows machine (since line ending normalization is turned off by default in Git). If you forget to set it up, you’ll re-introduce CRLF
into the remote code. From my article:.editorconfig
is a text file that overrides the settings of the editor of your choice..editorconfig
you are able to override this settings with a simple text file that usually is checked in with your source code and available for all developers who work on those sources..editorconfig
it will use it immediately and it will check your code on every code change.eol
attribute, the Git config, and the platform (see explanation of eol
below)..gitattributes
file is a special file that tells Git how to handle specific files in your repository..gitattributes
in subfolders for rules that only apply there..gitattributes
file. Here's how you can do it:* text=auto eol=lf
*
: Matches all files in the repository.text=auto
: Tells Git to automatically detect text files.eol=lf
: Ensures that line endings are normalized to LF when files are checked out..gitattributes
:
git add --renormalize . git commit -m "Normalize line endings to LF"
to be continued
I am trying to figure out how to add a custom file type to be recognised by Netbeans.
I am editing .tpl files and I would like them to be recognised as PHP/HTML files.
Solution
This option will use default editor colour, so no colouring any more.
If you upgrade your Java SDK, the NetBeans IDE may give you the following error message (Invalid jdkhome specified) at startup:
Cannot find java.exe in specified jdkhome.
Neither C:\Program Files\Java\jdk1.6.0_10\jre\bin\java.exe
nor C:\Program Files\Java\jdk1.6.0_10\bin\java.exe exists.
Do you want to try to use default version?
This can be corrected by manually editing the netbeans.conf
file found under:
%PROGRAMFILES%\NetBeans 6.5\etc
Replace the line netbeans_jdkhome
with the correct path information. Alternatively, you can comment out the line entirely with #
and NetBeans will use your default JDK, through JAVA_HOME
.
In Netbeans using SVN Subversion you get the following error when you try and sync/checkout files.
svn: Repository UUID '1a063a9b-81f0-0310-xxxxx etc' doesn't match expected UUID '7be80a69-xxxxxx etc'
(I've xxxxx'd out some of the UUID numbers in case they were sensitive in nature)
Notes
Solution
This will be a collection of preferred settings for netbeans. This will prevent me hunting to change that one setting for that annoying feature.
Disable mysql auto closing
When you press return/enter to split SQL statements, Netbeans automaticlly closes the statement and then re-opens it. This makes the code evern messier.
options --> editor --> code completion --> PHP language --> disable 'Use String Auto-Concatenation after Typed Break'
These are some examples of searches in netbeans using a Regex pattern
So i want to change some <input> tags.
<input .....> to <input ..... />
The following will search for all <input strings that do not terminate in />
Search String: <input(.*)([^\/])> Replacement String: <input$1$2 />
However this does not take into account of whether there is a space at the end so I need to do another search for:
<input(.*)({space}){2}\/> - needs finishing
Notes
[^\/]
A minor issue is that the built in Netbeans Subversion integration doesn’t work in a 64-bit install. It helpfully provides a link to the Subversion client software at CollaNet, however the most recent version for Windows is v1.5.5 which isn’t a lot of help if you are using Subversion 1.6.x.
Here I will give the basic instructions on how to use GitHub with Netbeans. I can be confusing at the beginning but does get easier.
Keep files in the project folder