Ask not what Notepad++ can do for you - ask what you can do for Notepad++
Bug reports are appreciated. Following a few guidelines listed below will help speed up the process of getting them fixed.
- Search the issue tracker to see if it has already been reported.
- Disable your plugins to see if one of them is the problem. You can do this by renaming your
plugins
folder to something else. - Only report an issue with a plugin if it is one of the standard plugins included in the Notepad++ installation. Any other plugin issue should be reported to its respective issue tracker (see e.g. plugin_list_x86.md or plugin_list_x64.md to find the homepage with further information on that for a plugins). The standard plugins include (for v7.9.5):
- NppExport
- Converter
- mimeTools
- Fill the complete information: a template will be shown when you create an issue. Please fill the complete information in the template. To fill the field Debug Information you can get it from your Notepad++ via menu
?>Debug Info...
. Please take your time to fill these information. If you don't bother to complete the information we need to help you, we won't bother to solve your problem either.
Your pull requests are welcome; however, they may not be accepted for various reasons. If you want to make some GUI enhancement like renaming some graphic items or fixing typos, please create the issue instead of the pull requests. All Pull Requests, except for translations and user documentation, need to be attached to a issue on GitHub. For Pull Requests regarding enhancements and questions, the issue must first be approved by one of project's administrators before being merged into the project. An approved issue will have the label Accepted
. For issues that have not been accepted, you may request to be assigned to that issue.
Opening an issue beforehand allows the administrators and the community to discuss bugs and enhancements before work begins, preventing wasted effort.
- Respect existing Notepad++ coding style. Observe the code near your intended change, and attempt to preserve the style of that code with the changes you make.
- Create a new branch for each PR. Make sure your branch name wasn't used before - you can add date (for example
patch3_20200528
) to ensure its uniqueness. - Single feature or bug-fix per PR.
- Create a PR with a single commit to make the review process easier.
- Make your modification compact - don't reformat source code in your request. It makes code review more difficult.
- PR of reformatting (changing of ws/TAB, line endings or coding style) of source code won't be accepted. Use issue trackers for your request instead.
- Typo fixing and code refactoring won't be accepted - please create issues with title started with
TYPO
to request the changing. - Address the review change requests by pushing new commits to the same PR. Avoid amending a commit and then force pushing it. All the PR commits are squashed before merging to the main branch.
- When creating new PR, try to base it on latest master.
- Don't merge
upstream/master
(using git or via github sync), if your PR is based on olderupstream/master
. If you need to base it on latestmaster
(e.g. to check and fix merge conflict), use commandsgit fetch upstream
to get latestmaster
and thengit rebase upstream/master
to rebase it onto this latestupstream/master
. - Finally, please test your pull requests, at least once.
In short: The easier the code review is, the better the chance your pull request will get accepted.
-
Do not use Java-like braces
- Good:
void MyClass::method1() { if (aCondition) { // Do something } }
- Bad:
void MyClass::method1() { if (aCondition) { // Do something } }
However, the method definition could be defined in a header file (.h), if there's one line code only. In this case, Java-like braces should be used.
- Good:
class MyClass { public: void method1(); int method2() { return _x; // only one line code can be placed in .h as method definition }; private: int _x; }
-
Use tabs instead of white-spaces (we usually set our editors to 4 white-spaces for 1 tab, but the choice is up to you)
-
Always leave one space before and after binary and ternary operators
- Good:
if (a == 10 && b == 42)
- Bad:
if (a==10&&b==42)
-
Only leave one space after semi-colons in "for" statements
- Good:
for (int i = 0; i != 10; ++i)
- Bad:
for(int i=0;i<10;++i)
-
Function names are not separated from the first parenthesis
- Good:
foo(); myObject.foo(24);
- Bad:
foo ();
-
Keywords are separated from the first parenthesis by one space
- Good:
if (true) while (true)
- Bad:
if(myCondition)
-
Switch
- Use the following indenting for "switch" statements:
switch (test) { case 1: { // Do something break; } default: // Do something else } // No semi-colon here
- If possible use
default
statement, and prefer using it as last case. - When using switch with enum or known range, try to cover all values if not using
default
.
enum class Test {val1, val2, val3} switch (Test) { case Test::val1: { // Do something break; } //case Test::val2: //case Test::val3: default: // Do something else } // No semi-colon here
When using
default
adding uncovered values as comments can help to convey intention.- Use
[[fallthrough]]
if fall through is intended.
switch (test) { case 1: { // Do something } // I want fall through // adding comment can help to convey intention [[fallthrough]]; case 2: { // Do something break; } default: // Do something else } // No semi-colon here
-
Avoid magic numbers
- Good:
if (foo == I_CAN_PUSH_ON_THE_RED_BUTTON) startTheNuclearWar();
- Bad:
while (lifeTheUniverseAndEverything != 42) lifeTheUniverseAndEverything = buildMorePowerfulComputerForTheAnswer();
-
Prefer enums for integer constants
-
Use initialization with curly braces
- Good:
MyClass instance{10.4};
- Bad:
MyClass instance(10.4);
-
Always use
empty()
for testing if a string is empty or not- Good:
if (!string.empty()) ...
- Bad:
if (string != "") ...
-
Always use
C++ conversion
instead ofC-Style cast
-
Generally, all the conversion among types should be avoided. If you have no choice, use C++ conversion.
-
Good:
char aChar = static_cast<char>(_pEditView->execute(SCI_GETCHARAT, j));
- Bad:
char aChar = (char)_pEditView->execute(SCI_GETCHARAT, j);
-
-
Use
!
instead ofnot
,&&
instead ofand
,||
instead ofor
- Good:
if (!::PathFileExists(dir2Search))
- Bad:
if (not ::PathFileExists(dir2Search))
-
Always initialize local and global variables
- For primitive types and enum prefer initialization with
=
. - For other prefer
{}
-initializer syntax. - For "numerical" variables using literal suffix can help to convey intention.
constexpr float g_globalVariable = 0.0F; void test() { constexpr UINT strLen = 1024U; wchar_t myString[strLen]{}; }
- For primitive types and enum prefer initialization with
-
Classes uses Pascal Case
- Good:
class IAmAClass {};
- Bad:
class iAmAClass {}; class I_am_a_class {};
-
Methods & method parameters
- Use camel Case
void myMethod(uint myVeryLongParameter);
-
Member variables
- Any member variable name of class/struct should be preceded by an underscore.
public: int _publicAttribute; private: int _pPrivateAttribute; float _pAccount;
-
Always prefer a variable name that describes what the variable is used for
- Good:
if (hours < 24 && minutes < 60 && seconds < 60)
- Bad:
if (a < 24 && b < 60 && c < 60)
-
Use C++ comment line style rather than C comment style
- Good:
// Two lines comment // Use still C++ comment line style
- Bad:
/* Please don't piss me off with that */
-
Use C++11/14/17/20 whenever it is possible.
-
Use C++11 member initialization feature whenever it is possible.
class Foo { int value = 0; };
-
Incrementing
- Prefer Pre-increment
++i
- Over Post-increment
i++
(It does not change anything for built-in types but it would bring consistency)
-
Avoid using pointers. References are preferred instead. You might need the variable to be assigned a
NULL
value: in this case theNULL
value has semantics and must be checked. Wherever possible, use a SmartPtr instead of old-school pointers. -
Avoid using new if you can use automatic variable. However, avoid
shared_ptr
as much as possible. Preferunique_ptr
instead. -
Don't place any "using namespace" directives in headers.
-
Compile time is without incidence. Increasing compile time to reduce execution time is encouraged.
-
Code legibility and length is less important than easy and fast end-user experience.
-
Prefer
constexpr
overconst
if value can be evaluated at compile time. -
Check if there are helper functions in headers or lambda functions to reuse them instead of writing new code.
- Example
// in StaticDialog.h isCheckedOrNot(); setChecked(); // in Parameters.cpp parseYesNoBoolAttribute();
-
Check if there are already defined global variables, and reuse them instead of defining new ones.
-
Avoid "Yoda conditions".
- Good:
if (iAmYourFather == true) ...
- Bad:
if (true == iAmYourFather) ...
-
Check C++ Core Guidelines for additional guidelines.