Which text editors have a format code option? - text

I'm looking for a basic text-editor with code format like NetBeans or Intellij.
In NetBeans IDE and Intellij IDE you have the option format code.
Something like this,
if( a == b )
{
bla;
bla;
bla;
}
after using this feature it will look like this:
if( a == b ){
bla;
bla;
bla;
}
P.S. I want the same thing which NetBeans and Intellij are offering.
I want a text editor, because I'm at beginning with Java and the IDE's are not very good for a beginner.

Most text editors let you bind hot keys to commands. I use SciTE and bind a call to astyle on the current document to a function key. Astyle formats most of the languages reasonable well ( it makes a pig's ear of C99 designated initialisers, but apart from that it's good ) . Other source code formatters are available.

Almost any programmer's editor or IDE will re-format code. You mention NetBeans and InelliJ in your question, but you don't mention why they aren't meeting your needs. Without more information, all you're likely to get is a list of editors, which isn't going to help you much.
What, specifically, are your requirements?

I'm not sure if it will change the location of curly-braces (on the same line versus a separate line) but vim (a text editor, available on doze and *nix) will fix indentation.
I find the "==" command to be the most useful. Or, in command mode, going to the top of the file and invoking "=G" will properly indent the entire file.
Summary of vim indentation options:
http://vim.wikia.com/wiki/Indenting_source_code
Official documentation of vim indentation options:
http://www.vim.org/htmldoc/indent.html

The Zeus editor can do this by running a macro script and these scripts can also be bound to the keyboard.

Check Code-Chameleon.
It Supports many languages.

emacs supports fill-region which will format any selected region of code according to the current mode.
You might find mark-whole-buffer and mark-sexp useful in this context.
For c-like languages there is support for a vast panoply of different styles. Read the documentation associated with the variable c-file-style. (Though why anyone would not use the One True Brace Style is beyond me...)

Related

Vim - Mimic ZenCoding/Emmet for other languages (like ZenSharp for C#)?

I have only tried Vim a few times, and am thinking of jumping in fully, but I was wondering if it had a feature similar to ZenSharp for ReSharper?
Eg. if I type ppiCount+ it would expand to:
public int Count { get; set; }
You use similar mnemonics for properties, fields, and classes. It's based on ZenCoding/Emmet.
Unfortunately I don't know much about Vim at all so I didn't get too far with googling. Would something like Vim macros work here? Or a Vim plugin like YouCompleteMe?
FYI, I'm going to be using VsVim for Visual Studio.
VsVim doesn't support the macro language of Vim. VsVim gives you a lot of the editing goodness of Vim, I have a guide ( a little out of date now, I'm looking to completely rewrite it at some point! ) here https://github.com/keithn/vsvimguide that shows how to try and make R# and VsVim work together ( or at least give ideas on how you might want to customize it )
The big thing is, you can mix in VsVim with other third party plugins, however sometimes there are weird conflicts depending on how the thirdparty thing works. However you can make vim bindings to plugins to get a more "vim" like experience, my article shows how to do that for R# commands.
So VsVim doesn't replace things like R# and other useful plugins, however sometimes they don't play nicely together, so you should be able to keep using ZenSharp. If it was the REAL Vim, then yes, you could use the macro language ( or find pre done plugins for Vim ) to do snippets on steroids.

C++ Cross Ref for VIM similar to Source Insight

I wanted a cross reference navigation similar to Source Insight.
Lets take simple example:
classA::MethodB()
{
...
m_variable = value;
}
In this example if I use Ctags / Cscope, then when I try to find m_variable, it will show me all the available m_variable. I need to go through each and then find which one is required.
Where as in Source Insight, it clearly gives me the Class delectation.
Is there any such Cross ref tools available for Vim?
Vim is not an IDE, it's a text editor.
You can't reasonably expect it to understand your code as well or as deeply as an IDE.
IDEs typically keep a dynamic internal representation of your code which makes them able to track declaration and usage even when you have dozens of methods or variables with the same name. Vim, like most text editors, is not able to do that on its own: it must rely on external tools for indexing/navigating through your code. Now, because of architectural constraints, Vim is incapable of running any background process which is the absolute prerequisite for a real "code intelligence" to be added to Vim.
Given all that, you are left with code indexers like ctags, cscope or GLOBAL. These tools do their best trying to give you accurate results but they are not as smart and as specific as the tools used in IDEs.
To compensate, Vim has a bunch of different commands like :tselect or g] which open a list of possible tags to chose from. Read :h tags, :h ctags and :h cscope for how to deal with those limitations.
I've not tried this myself. But sounds like eclim is what you're looking for. http://eclim.org/
It provides eclipse features to be accessible from Vim, including code searching and auto-completion.

VIM as an IDE - Suggestions

I am looking for recommendations on using VIM as an IDE. I generally code in a number of programming languages, including C, C++, assembler, MATLAB, Maple, BASH scripts, to name a few.
In general, I like to use a single IDE for the bulk of my projects for the sake of consistency, and I have found that I perform about 90% of all my coding in VIM, and occasionally use Eclipse instead for certain projects in C/C++ (ie: projects people have already put together as an Eclipse project, or PIC24/32 projects from www.microchip.com).
I am already very familiar with the basic functionality of VIM (windows vs buffers, text manipulation, scripting), and would like to use it as my primary IDE. I have already taken a few tips from here:
http://vim.wikia.com/wiki/Use_Vim_like_an_IDE#Writing_Code
I already use the nerdTree plugin for directory browsing in a project, etc, but I need to do something about code completion and symbol resolution, as those are my two greatest concerns.
Symbol resolution
I have some limited experience in the use of C-tags, and wanted a suggestion on what I should use if I am working with a VERY large code-base that changes frequently. The projects I work on typically are pulling in header files from at least a dozen other projects, and I would like to be able to jump to the file where a function, constant, or macro is defined quickly (ie: like the CTRL-G feature in Eclipse, "jump to definition"), as well as rapidly get a list of all calls/references to a function/macro/constant/etc (ie: like the CTRL-SHIFT-G feature in Eclipse, "Show all references in project or current working directory").
Tab completion
One of the features I really like in Visual Studio and Eclipse, for example, is when I type in a variable name (ie: pointer to struct) and it resolves the names and types of all structure members and gives me a tab completion list to choose the appropriate member. They also point out when I've incorrectly used "." vs "->" for member access. I've tried superTab in VIM, but I just couldn't get it working. I also want the tab-completion feature to use the same C-tags as generated by the symbol resolution plugin
Handling build output
The final concern of mine is having an auto-generated list of build warnings and build errors. When I, for example, just run "make all" at the command-line prompt, it is a pain to have to read through code listings to manually find all build warnings.
I realize this is a lot to ask, and that I could always just fall-back to Visual Studio or Eclipse, but I really want just a simple cross-platform console-capable modal editor for all my development needs, and none of the major IDE's out there fill this need.
Thank you all in advance.
http://eclim.org/ - bring Eclipse functionality to the Vim editor
https://github.com/scrooloose/syntastic - syntax checker warnings in quickfix list
I think (but haven't checked) that Eclim satisfies #1 and #2 while I'm sure that Syntastic satisfies #3. More things of interest:
https://github.com/Lokaltog/vim-powerline - just nice
https://github.com/kien/ctrlp.vim - quick file finder
https://github.com/tpope/vim-pathogen - plugin manager (to install the others)
And are you aware of omnicompletion via Ctrl-p and Ctrl-n (prev and next) in insert mode? That's not code completion, but frequently does the job.
For the auto-completion part (point 2), I am proficiently using clang_complete.
For a quick setup and reference, try this page: http://zwiener.org/vimautocomplete.html
EDIT: this is for C, C++ and Objective-C only.
I use the following configuration in vim:
zipped file
It has autocomplete based on tag list, ctags, nerd commenter and some more plugins.
Hope it helps.. :)
I have been using Vim as an IDE for about a year now. All of my customization is online at github.
That said, I don't think a Vim beginner should start using vim like this; rather I think the Vim beginner should learn vim incrementally. The only changes that I think are so essential I would make them from the very beginning are:
Remap ESC to jk
Switch : and ;
Set leader key to ,

Auto code completion in VIM?

Can VIM do auto code completion like what Eclipse does? Usually I connect to my Linux developing server through Putty from my Windows laptop. So, I hope I can find a plugin for VIM which can do drop-down menu like auto completion when I can type variable names in Putty, is this possible?
Thanks!
Yes, in a sense - Vim has Completion commands that can help you automatically find the completion text for partial variable names.
In a nutshell, type a partial variable name and then press CtrlP to search for a matching name.
Yes, it's possible. Vim already features that general style of code completion built-in, under the name of Omni completion.
The default installation doesn't allow for auto-invocation, but if you install this script, that allows it to happen.
Note that, depending on the language you'll be working with, you may need additional scripts to handle auto-completion for that language, and may even need to change the auto-invoke script to recognize when to invoke the completion. Since you haven't said what programming language you'll want to work with, it's a bit hard to say if you need more than this, but I recommend checking the help file.
Try to use http://eclim.org/ - using eclipse core with VIM via plugins.
To not start the complete ecplise core but have a C/C++ member completion, try
http://www.vim.org/scripts/script.php?script_id=1520
- Complete namespaces, classes, structs and union members.
- Complete inherited members for classes and structs
(single and multiple inheritance).
- Complete attribute members eg: myObject->_child->_child etc...
Currently vim has no of plugins for the auto code completion feature, I am using youcompleteme plugin, combined with vim-snippets, ultisnips and supertab plugins. You can tab complete the code using snippets (a small text which can be expanded for full code), and a large number of languages are supported.
For simple text files also a drop down menu comes for the words you have typed earlier.

Vim for Word (or something like it)

Are there any rich-text editors that have Vi(m) keybindings? Specifically, something like Word where I can compose a document with colors, headings, et al. but use Vi(m) bindings to move around and compose?
So if you have to use MS Word and want vim key bindings, there is an add on, but if you are not bound to that I would def. go for LaTeX + the vim latex suite.
Are you familiar with Latex?
Simply put it allows you to format your documents in plain text using tags or commands.
You then "compile" your document into the final format .pdf,.ps, etc.
Ex:
\documentclass{article}
\title{Cartesian closed categories and the price of eggs}
\author{Jane Doe}
\date{September 1994}
\begin{document}
\maketitle
Hello world!
\end{document}
This will allow you to write in vim, but still get professional non plain text output for your documents.
If you like Markdown or Latex, you could use the free open source Rstudio editor, with VIM-mode enabled. Export as either Word, PDF, or HTML etc.
Download Rstudio:
https://www.rstudio.com/products/RStudio/#Desktop
Read about markdown:
http://rmarkdown.rstudio.com/
If you wish to use vim for text editing, but want to, for example have text in different colors, bold it and such ... you can use Txtfmt plugin. It enables you, by using special characters, to "prettify" plain text files a little. They can look quite nice, and it comes handy if you're used to vim, and are, for example, writing documentation for your programs which you'll later just get in word, and make an adjustment or two, and ship off.
If you want to (or have to) stay with Word and don't want to shell out $100 for a ViEmu license, you can try using this AutoHotKey script for providing some basic vi-like functionality. The repo linked also provides a standalone exe to get the same without using AutoHotKey.
There are many good reasons to ditch word entirely, but sometimes that's just not an option :(
The Txtfmt plugin definitely provides the functionality you are looking for. It's a bit like having "rich text" capability for plain text in Vim.
Txtfmt (The Vim Highlighter)
Screenshots
The latest version supports 8 configurable foreground and background colors, as well as all combinations of bold, underline, italic, etc... The highlighting is token-based, but the tokens are rendered invisible by the syntax, and can be inserted with very convenient and intuitive mappings, which don't require you to remember anything: e.g., "bold-underline" could be specified with a string such as bu or ub. The version under development even supports visual maps, which will permit you to select some text and say (for example) "Make this text red, bold-italic", and have the plugin handle insertion/removal of the appropriate tokens automatically. (It's really quite simple and intuitive, however, even with the non-visual mappings.)
Although the plugin is highly configurable, the default settings are appropriate for most users, and the author is more than happy to answer any setup or usage questions...
There's a way of configuring Abiword to use vi key bindings
You can use the text editor of your choice with vim keys (vim, emacs, sublime, atom, vscode ,etc.) and write your document in markdown. Then use an open source tool called pandoc to translate it into almost any other markup language that you want. It is possible to compile your document to rich text formats including MS Word or even MS Powerpoint.
You can costumize your output by using a template.
Pandoc has extensive documentation and uses a richer markup syntax that allows you to do pretty much anything you want with the text. It is being actively developed by the community. Almost any major text editor has a few plugins for pandoc too.
You can use GlobalVim.
It can simulate vim modes and commands in most editing area.

Resources