Table of Contents

Class NppUtils

Namespace
Npp.DotNet.Plugin.Extensions
Assembly
Npp.DotNet.Plugin.dll

Miscellaneous helper methods for some common use cases.

public static class NppUtils
Inheritance
NppUtils
Inherited Members

Fields

NppVersion

The major, minor and patch version numbers of the currently running edition of Notepad++.

public static readonly (int, int, int) NppVersion

Field Value

(int, int, int)

NppVersionAtLeast8

true if the currently running edition of Notepad+ is version 8.0.0 or newer.

public static readonly bool NppVersionAtLeast8

Field Value

bool

NppVersionStr

The full version of the currently running edition of Notepad++, as a string.

public static readonly string NppVersionStr

Field Value

string

Properties

AssemblyVersionString

Gets the version of the currently executing assembly as a formatted string.

public static string AssemblyVersionString { get; }

Property Value

string

ConfigDirectory

The full path to the common directory where plugin configuration files are saved.

public static string ConfigDirectory { get; }

Property Value

string

Methods

AddLine(string)

Appends the given text (with a newline) to the current buffer and moves the caret.

public static void AddLine(string text)

Parameters

text string

CreateConfigSubDirectoryIfNotExists()

Creates the common directory where plugin configuration files are saved, if it doesn't already exist.

public static void CreateConfigSubDirectoryIfNotExists()

FileExtension(string)

Gets the file extension (not including the period) of the file at the given path. The currently active file is used if no path is given.

public static string FileExtension(string path = null)

Parameters

path string

Returns

string

GetCurrentPath(PathType)

Gets one of:

  • the full path of current file (default);
  • the full path to the directory of the current file; or,
  • the name of the current file
public static string GetCurrentPath(NppUtils.PathType which = PathType.FULL_CURRENT_PATH)

Parameters

which NppUtils.PathType

Returns

string

Exceptions

ArgumentException

Thrown if which is not a value of NppUtils.PathType.

GetSlice(Position, Position)

Gets the range of text between the given start position and the given end position in the current document.

public static string GetSlice(Position start, Position end)

Parameters

start Position
end Position

Returns

string