Gedit adds recognition of specified file formats (such as qml) and enables appropriate syntax highlighting

Source: Internet
Author: User
Tags globs

Gedit adds the recognition of specified file formats (such as qml) and enables appropriate syntax highlighting. I believe everyone in linux is familiar with the Notepad program gedit. Today, let's share some knowledge about syntax highlighting rules. www.2cto.com 1. function description we know that qml is a javascript language, developed by Qt, later, ubuntu was used to maintain the logic on the upper layer of the interface. For example, Ubuntu Phone is used. Recently, I want to learn Ubuntu Phone related technologies, so I plan to take a look at the qml file of the source code; by default, it is displayed in plain text mode when opened with gedit. You can manually set the File Syntax highlighted format in the bottom status bar. For example, it is much more comfortable to select it as JavaScript; [reserve an image location] it is very difficult to manually set multiple files to be opened one by one. Why cannot I automatically identify qml as javascript? Linux is a "lazy". I don't like to handle too many things manually. I want to give a few commands and then everything will naturally adapt to my own ideas; in windows, files can be connected to different programs, which is only a basic step. in linux, you can also set the default program, but we want to be more advanced, let the program automatically identify the text to be processed, so it takes a lot of effort; 2. Explanation of the principle 2.1 gedit is highlighted by a lot of syntax, you can choose from the menu -- View -- Highlight mode. 2.2 gedit is selected by many Color schemes and can be set in menu -- Edit -- Preference -- Font & Color. classic is generally eye-catching; syntax highlighting rules and processing is handled by another tool, called: gtksourceview-3.0, you search for this tool is clear; 3, the processing method said so much nonsense, now you need to support the qml file to identify it as JavaScript and syntax highlighting; 3.1 directly edit the configuration file: sudo vi/usr/share/gtksourceview-3.0/language-specs/javascript. lang: This is an xml file. globs is used to identify the file in 30 lines: <property name = "globs"> *. js ;*. node ;*. qml </property>. The red part is the added content. The next time you open the qml file with gedit, the file will be automatically highlighted; <language id = "js" _ name = "JavaScript" version = "2.0" _ section = "Scripts"> <metadata> <property name = "mimetypes"> application/javascript; application/x-javascript; text/x-js </property> <property name = "globs"> *. js ;*. node ;*. qml </property> <property name = "line-comment-start"> // </property> <property name = "block-comment-start">/* </property> <property name = "block-comment-end"> */</property> </metadata> 4. Additional contributions: usually open several files are closed gedit sidebar, F9 open sidebar, you can choose File Folder mode, you can see the navigation of the entire directory, to facilitate the switching of multiple files; source http://www.cnblogs.com/QuLory/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.