If you are looking for a lightweight code editor with a lot of perks, try CudaText. Despite its small footprint, CudaText comes with a lot of features you’ll find only in advanced code editors. A plugin based architecture makes the editor extensible with many more possibilities. CudaText is written in Lazarus. The Linux GUI is written using GTK2. Continue reading CudaText: light code editor
Tag: code browsing
Sourcegraph: refer to open source code
Sourcegraph is a tool from opensource.com to semantically index all open source code available on the web. No doubt this will help is developing faster without the need to rebuild the wheel. The tool lets you “search for code by repository, package, or function and click on fully linked code to read the docs, jump to definitions, and instantly find usage examples. Continue reading Sourcegraph: refer to open source code
yavide: modern C C++ IDE over vim
vim has numerous plugins for developers and when combined together it becomes far more powerful than any IDE out there. The additional advantage is the resource consumption, it’s minimal when compared to Eclipse or NetBeans and the likes of those. This also makes a vim based IDE ideal for remote programming. yavide is a new project that takes these vim plugins seriously and tries to package everything together. It also aims to provide some features not available in any other IDE. In its current status (at the time of writing), yavide looks like the next step from spf13-vim. yavide is still in the development phase and yet to see its first release at the time of writing. However, the author is working on missing and requested features.
Features
- Bundled and tweaked for C/C++ (support for Python & Java planned)
- Project management & Project explorer
- Class browser with overview of symbols defined in current unit (i.e. macro, struct, class, method, namespace, etc.)
- Source code auto-completion (real C/C++ compiler back-end for correctness)
- Source code navigation (fully automated background tag generation system to ensure the best UI experience)
- Source code static analysis
- Source code management client integration (git integrated)
- Build tools (make integrated)
- Custom keybinds for various operations
- Miscellaneous:
> syntax highlighting
> highlight all occurrences
> parenthesis auto-complete
> context-aware ordinary text auto-complete
> multiple-selection editing support
> code snippets
> grep support
> bash shell integration
> color schemes support
Plugins
The following vim plugins are integrated into yavide at the time of writing:
- A
- Clang_complete
- NERDTree
- NERDCommenter
- SuperTab
- Tagbar
- vim-airline
- UltiSnips
- vim-autoclose
- vim-fugitive
- vim-gitgutter
- vim-multiple-cursors
- vim-pathogen
Installation
To install yavide dependencies on Ubuntu, run:
$ sudo apt-get install build-essential vim-gnome python2.7 git libclang-dev python-dev
Run the following commands to clone the git repository of yavide and install it:
$ cd ~/ && git clone https://github.com/JBakamovic/yavide.git $ cd yavide && ./install.sh
Replace with the location where you want to install yavide. The deault is /opt. yavide will create its own directory and install the files within it.
On GitHub: yavide
Ohloh & other code search engines
Developers often search Google for reference code. Whereas Google search returns generic results there is a specialized tool for this purpose. Ohloh Code Search is a high performance open source code search engine. You can search code with numerous criteria and it returns you the results instantly. Features:
- Search 21,280,539,120 lines of open source code
- Search criteria like classes or structures whose name contain, compound searches, exact matches and so on
- Filter results by definition (function, class, field…), project, language or file extension
- Clean interface, easy navigation between results
Code Search uses the enterprise standard Code Sight indexing and search engine under the hoods. If you want to use Code Sight locally you can download the free and limited to 200K lines of code edition from here.
Webpage: Ohloh Code Search, Code Sight
Other options
- GitHub
- Codase
- Krugle
- searchcode
Turn vim into Source Insight
An earlier article on ctags and cscope may be a good starting point for the current one.
Source Insight is a very popular code editor cum browser on Windows and can be used on Linux over Wine as well. However, the same can be done using vim with some practice. The Trinity plugin for vim does it all. Trinity makes 3 more plugins work in unison to deliver you an IDE like experience. You can have the similar look and feel and functionality of Source Insight over vim at a reduced number of CPU cycles. And when using remotely… heaven!
Transform vim into the most powerful and lightweight IDE you ever used!
Features
- Automatic Display of Declarations in the Context Window on the bottom in the (G)VIM window using the Source Explorer plugin
- Symbol Windows For Each File on the left in the (G)VIM window (G)VIM using the Taglist plugin
- Quick Access to All Files on the right in the (G)VIM window using the NERD Tree plugin
Installation
- Download the latest version of Trinity
$ git clone https://github.com/wesleyche/Trinity.git
- Copy the trinity.vim and NERD_tree.vim files under plugin directory into the vim plugin directory e.g. ~/.vim/plugin
Configuration
Add the keybinds for the 3 plugins to your ~/.vimrc
" Open and close all the three plugins on the same time nmap :TrinityToggleAll " Open and close the srcexpl.vim separately nmap :TrinityToggleSourceExplorer " Open and close the taglist.vim separately nmap :TrinityToggleTagList " Open and close the NERD_tree.vim separately nmap :TrinityToggleNERDTree
Webpage: Trinity
Some more useful tips:
ctags & cscope: the fastest IDE
If you are a Linux developer, there is no alternative to the deadly combination of ctags and cscope when it comes to source code browsing and editing. I remember years back, out of mere curiosity I started learning them one evening and ended up in practicing throughout the night to get accustomed. I am a fan of ctags and cscope since then. They are much much lighter and faster than any other IDE I have laid my hands on.
ctags and cscope are the solutions to all your code browsing needs
Installation
To install on Ubuntu:
$ sudo apt-get install exuberant-ctags cscope
Usage
I added the following in my .bashrc to generate the tags and cscope file data:
function ta () { #clean older info rm -rf tags rm -rf cscope.files rm -rf cscope.out # generate new info find $PWD | egrep -i "\.(c|h|cpp)$" > cscope.files ctags -R . *.c *.h *.cpp --tag-relative=yes ./ }
To generate tags and cscope file information, navigate to the root directory of your project and run
$ ta
Troubleshooting on SuSE
I got the following error repeatedly on SuSE while trying to open tag search results (though it worked well on Ubuntu):
E429: File "/path/to/file.c" does not exist
Here are the steps I followed to fix it:
- Generate cscope.files with absolute path
$ find /path/to/project/files | egrep -i "\.(c|h|cpp)$" > cscope.files
- Generate the tags file
$ ctags -R . *.c *.h *.cpp --tag-relative=yes ./
A list of excellent tutorials, tips etc. to learn ctags & cscope:
- Browsing programs with tags
- The Vim/Cscope tutorial
- Jumping to the declaration of a local/global variable
- Vi and Vim Editor: 12 Powerful Find and Replace Examples
- ctags and cscope
- Ctags and Taglist
- Jumping to previously visited locations
The only plug-ins I use:
- MiniBufExplorer
NOTE: Add ‘set hidden
‘ in your ~/.vimrc not to lose syntax highlighting when you close a buffer. This hides the buffer instead of closing them. vim has a bug which causes loss of syntax highlighting on a buffer quit. - Taglist
- CScope maps
- a.vim
Some pointers:
- search word under cursor:
<Shift-#>
- find file with pattern in cscope:
cs f fe file
//check cscope_maps.vim for other switches - to list all possibilities: type
:ts IPPR
and then press<Ctrl-d>
<Ctrl-]>
jumps to definition while<Ctrl-o>
returns to previous location (double<'>
does the same too).<Ctrl-i>
jumps forward.
Some handy .vimrc entries to enjoy your mug of vi:
set ai //leads to scattered code when pasting in remote terminal (like PuTTY) on Windows, //run set noai first to avoid. set cindent //c like indentation set ic //ignore case while searching set incsearch //incremental search during typing set hlsearch //highlight search matches set ts=4 //tab length set sw=4 //shift width, amount on shift you want in new lines set nu //show line numbers
Happy coding! 🙂