Why does NP++ reformat my php code?

  • Why does notepad++ reformat my script. I opened my script yesterday and everything was double-spaced. Today I opened it and it was all jumbled up, like this:

    $todaynbr = date("d");	$today = date("Y-m-d");	$monDays = cal_days_in_month(CAL_GREGORIAN, $monthnbr, $year);	$firstday = date("w", mktime(0, 0, 0, $monthnbr, 1, $year)); 	$lastday = date("t", mktime(0, 0, 0, $monthnbr, 1, $year)); 	$num_of_weeks = 1 + ceil(($lastday-7+$firstday)/7);	$dateObj   = DateTime::createFromFormat('!m', $monthnbr);	$monname = $dateObj->format('F'); 		$firstdayofMonth = date("l", mktime(0, 0, 0, date("$monthnbr"), 1, date("$year")));	$day_of_week = date('N', strtotime($firstdayofMonth));
    $tgl = '01' . $monname . $year;	$lastMonth = date("M Y",mktime(0,0,0,date("m", strtotime($tgl))-1,1,date("Y", strtotime($tgl))));	$lmonth = date('m',strtotime($lastMonth));	$nextMonth = date("M Y",mktime(0,0,0,date("m", strtotime($tgl))+1,1,date("Y", strtotime($tgl))));	$nmonth = date('m',strtotime($nextMonth));
    $string="$lastMonth";	$last_space = strrpos($string, ' ');	$last_yr = substr($string, $last_space);	$last_mon = substr($string, 0, $last_space);

    The script still work but why doesn’t it just leave the damn code alone? Editing it is a pain in the ass if I have to reformat 400 lines manually.

  • Notepad++ does not mess with any code like that. Either you:

    • Have a plugin that is somehow modifying the code
    • Are accidentally hitting a shortcut key (e.g. Ctrl+J to join all the lines)
    • Or something outside of Notepad++ is modifying it (for example mixing up line endings)

Log in to reply