4

I am using systemverilog very often.
I am using UltraEdit as text editor. I use also VIM.
Sometimes I have to copy code from some other places and paste it into my code.
It may not be indented properly. It is a difficult task to indent it properly again.

Can anybody suggest any method or tool to do it easily?

Mofi
  • 46,139
  • 17
  • 80
  • 143
Vineeth
  • 111
  • 2
  • 11

3 Answers3

9

Method

  1. Visit EDA Playground
  2. Paste your code into one of the editor windows
  3. Select all text with CTRL-A
  4. Reindent all text with SHIFT-TAB

Some backgroud

There is a Verilog mode for Code Mirror which supports SystemVerilog. CodeMirror is an in-browser text editor written in JavaScript which is used on a number of websites, including EDA Playground.

You could also paste and reindent in the example window here, or you could download it yourself and run it locally.

dwikle
  • 6,820
  • 1
  • 28
  • 38
2

The verilog mode in Emacs supports indentation, so you can open your file in Emacs (from the command line, run emacs file-name.v, select all by pressing Ctrl+H, then reindent by pressing TAB and save with Ctrl+S.

Clément
  • 12,299
  • 15
  • 75
  • 115
0

UltraEdit has command ReIndent Selection at bottom of menu Format.

All lines of a selection of any type of text file can be re-indented (not reformatted, i.e. not inserting line breaks or removing line breaks) with this command as long as

  1. the file is syntax highlighted based on a wordfile (*.uew) suitable for type of text file,
  2. the syntax highlighting wordfile contains appropriate indent/unindent string definitions.

Therefore it is no problem to re-indent code after paste by selecting pasted block and use the command ReIndent Selection with a good syntax highlighting wordfile for SystemVerilog.

The syntax highlighting wordfile currently used for active file can be opened for editing or improvement by clicking on button Open left of language list box preselected according to used syntax highlighting for active file at Advanced - Setttings or Configuration - Editor Display - Syntax Highlighting.

The lines of interest in the wordfile regarding indent/unindent start with

/Indent Strings =
/Unindent Strings =
/Ignore Strings SOL =

More information about those three lines can be found

A user contributed syntax highlighting wordfile for SystemVerilog can be downloaded from wordfiles page.

Note: As command ReIndent Selection is a basic command for all languages, it is not as smart as tools written to re-indent or even reformat source files written for specific languages with true language intellisense like Artistic Style for C / C++ / C# and Java (also supported built-in by UE).

Mofi
  • 46,139
  • 17
  • 80
  • 143