zoukankan      html  css  js  c++  java
  • noi linux gedit 配置(c++环境)

    基本配置

    方法一

    查看所有命令:

    gsettings list-recursively | grep -i gedit
    

    命令解释

    gsettings set org.gnome.gedit.preferences.editor tabs-size 4
    //设置缩进
    gsettings set org.gnome.gedit.preferences.editor auto-save true
    //设置自动保存
    gsettings set org.gnome.gedit.preferences.editor auto-indent true
    //设置自动缩进
    gsettings set org.gnome.gedit.preferences.editor bracket-matching true
    //设置显示匹配括号
    gsettings set org.gnome.gedit.preferences.editor display-line-numbers true
    //设置行号
    gsettings set org.gnome.gedit.preferences.editor highlight-current-line true
    //设置高亮
    

    bash代码

    gsettings set org.gnome.gedit.preferences.editor tabs-size 4
    gsettings set org.gnome.gedit.preferences.editor auto-save true
    gsettings set org.gnome.gedit.preferences.editor auto-indent true
    gsettings set org.gnome.gedit.preferences.editor bracket-matching true
    gsettings set org.gnome.gedit.preferences.editor display-line-numbers true
    gsettings set org.gnome.gedit.preferences.editor highlight-current-line true
    

    保存文件为 set.sh

    终端运行 bash ./set.sh

    方法二

    直接通过编辑-首选项进行设置,太过简单不多描述。

    编译配置

    首先通过编辑-首选项-插件-外部命令来打开外部命令,然后在工具-Manage External Tools来添加新工具,工具代码使用bash语言。

    代码使用方式:+添加新插件,在编辑框中粘贴代码,快捷键:自定义,保存为:当前文档,输入为:当前文档,输出为:在下方面板中显示,适用范围为:所有文档 C++

    下面提供两种代码:

    代码一

    #!/bin/sh
    dir=$GEDIT_CURRENT_DOCUMENT_DIR
    name=$GEDIT_CURRENT_DOCUMENT_NAME
    pre=${name%.*}
    g++ $dir/$name -o $pre -g -Wall
    if test $? -eq 0; then
        gnome-terminal -x bash -c "$dir/$pre;echo;read;"
    fi
    

    这种代码会打开一个终端,然后需要手动输入。调试代码时,比较繁琐。
    那么我们就搞了一个更简单的方式。代码如下:
    代码二

    #!/bin/sh
    fullname=$GEDIT_CURRENT_DOCUMENT_NAME
    dir=$GEDIT_CURRENT_DOCUMENT_DIR
    name=${fullname%.*}
    inname=${name}.input
    outname=${name}.output
    ansout=${name}.ansout
    cd $dir
    cat $fullname | awk 'BEGIN{a=0} /*//{a=1} a==0{print $0}' | grep -v "/*" | cat > $inname
    cat $fullname | awk 'BEGIN{a=0} /*//{a++} a==1{print $0}' | grep -v ["*/""/*"]| cat >$outname
    g++ $fullname -o $name && ./$name <$inname >$ansout
    diff -a -b -B -c -q $ansout $outname && echo Accept || echo Wrong Answer
    cat $ansout
    rm $ansout $outname $inname $names -rf
    
    

    这个版本无需文件输入输出,只需要在文件头加入两个注释,第一个为样例输入,第二个为样例输出。

    举个例子:

    /*
    6
    1 30 3 2 3 4
    2 16 2 5 6
    3 5 0
    4 4 0
    5 11 0
    6 5 0
    */
    /*
    25
    */
    #include <iostream>
    using namespace std;
    ....<code>
    

    这样在编译时会在下方面板输出

    Running tool: 运行命令
    
    25
    Done.
    

    主题配置

    编辑-首选项-字体和颜色中有许多配色方案可以选择,这里我们在推荐一个,同样附上源码:

    <?xml version="1.0" encoding="UTF-8"?>
    <!--
        Copyright (C) 2011 Craig Russell
        Author: Craig Russell <craig@craig-russell.co.uk>
        This library is free software; you can redistribute it and/or
        modify it under the terms of the GNU Library General Public
        License as published by the Free Software Foundation; either
        version 2 of the License, or (at your option) any later version.
        This library is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
        Library General Public License for more details.
        You should have received a copy of the GNU Library General Public
        License along with this library; if not, write to the
        Free Software Foundation, Inc., 59 Temple Place - Suite 330,
        Boston, MA 02111-1307, USA.
    -->
    <style-scheme id="ubistive" _name="Ubistive" version="1.0">
        <author>tmz</author>
        <_description>qtmz</_description>
    
        <!-- Solarized Palette -->
        <color name="base03"  value="#000000"/>
        <color name="base02"  value="#041323"/>
        <color name="base01"  value="#233445"/>
        <color name="base00"  value="#456676"/>
        <color name="base0"   value="#839496"/>
        <color name="base1"   value="#A1A164"/>
        <color name="base2"   value="#EEE8D5"/>
        <color name="base3"   value="#FDF6E3"/>
        <color name="yellow"  value="#B58900"/>
        <color name="orange"  value="#CB4B16"/>
        <color name="red"     value="#DC322F"/>
        <color name="magenta" value="#D38662"/>
        <color name="violet"  value="#AC71C4"/>
        <color name="blue"    value="#268BD2"/>
        <color name="cyan"    value="#2AA198"/>
        <color name="green"   value="#A5AF00"/>
    
        <!-- Global Settings -->
        <style name="text"                        foreground="base1" background="base03"/>
        <style name="selection"                   foreground="base03" background="base00"/>
        <style name="cursor"                      foreground="base1"/>
        <style name="current-line"                background="base02"/>
        <style name="line-numbers"                foreground="base01" background="base02"/>
    
      
        <!-- Bracket Matching -->
        <style name="bracket-match"               foreground="base03" background="base01"/>
        <style name="bracket-mismatch"            foreground="red" background="base01"/>
    
        <!-- Search Matching -->
        <style name="search-match"                foreground="base03" background="yellow"/>  
    
        <!-- Comments -->
        <style name="def:comment"                 foreground="base01"/>
        <style name="def:shebang"                 foreground="base01" bold="true"/>
        <style name="def:doc-comment-element"     italic="true"/>
    
        <!-- Constants -->
        <style name="def:constant"                foreground="cyan"/>
        <style name="def:special-char"            foreground="green"/>
    
        <!-- Identifiers -->
        <style name="def:identifier"              foreground="blue"/>
    
        <!-- Statements -->
        <style name="def:statement"               foreground="orange"/>
    
        <!-- Types -->
        <style name="def:type"                    foreground="yellow"/>
    
        <!-- Operators -->
        <style name="def:operator"                foreground="green"/>
        <style name="def:bracket"                foreground="red"/>
        
        <!-- Others -->
        <style name="def:preprocessor"            foreground="violet"/>
        <style name="def:error"                   foreground="red" bold="true"/>
        <style name="def:note"                    foreground="magenta" bold="true"/>
        <style name="def:underlined"              italic="true" underline="true"/>
    
    </style-scheme>
    

    把它保存为a.xml。然后在回到编辑-首选项-字体和颜色中点击 + 号,然后选择a.xml文件,便可以添加主题。(ps:有推荐者欢迎在下面留言,谢谢)。

    自动补全

    gedit的自动补全叫做片段,不像vscode,gedit的片段只能进行一些简单的操作,比如打出for,然后按下tab键,这样会出现一个

    for (unsigned int i = 0; i < count; i += 1)
    {
    		
    }
    

    的代码片段,然后就可以通过移动tab键,来改变各个参量的值。同时可以通过工具-Manage Snippets来管理片段。

    嗯,就这些吧,若有疑问,随时留言。

  • 相关阅读:
    CentOS6.5配置MySQL主从同步
    CentOS6.5安装telnet
    linux 下安装Google Chrome (ubuntu 12.04)
    jdk w7环境变量配置
    JDBCConnectionException: could not execute query,数据库连接池问题
    注意开发软件的版本问题!
    linux mysql命令行导入导出.sql文件 (ubuntu 12.04)
    linux 下root用户和user用户的相互切换 (ubuntu 12.04)
    linux 下 vim 的使用 (ubuntu 12.04)
    linux 下安装配置tomcat-7 (ubuntu 12.04)
  • 原文地址:https://www.cnblogs.com/hellohhy/p/13176139.html
Copyright © 2011-2022 走看看