gedit配置记

gedit配置记

起因

突然感觉sublime用用这里那里不方便(虽然很好看> >),然后稍微手调了一下gedit发现gedit还是非常可用的(雾)...

阶段一

我感觉sublime各种不好用> >而且配色比较烦,编译也不好调> >,说白了就是比较复杂zball丝播不会调

然后我发现gedit可以一眼看穿(大雾),然后顺手调了一下gedit.

Configurations

  • gedit Alt-E(编辑) E(首选项) [tab1] 查看
    • on D(显示行号)
    • off M(显示对齐线)
    • off W(自动换行)
    • on L(hlt ln)
    • on B(hlt matched brackets)
  • [tab2] 编辑器
    • tabsize 〔3__|+|-〕 < <我是大异端
    • off S(空格代替tab)
    • on E(auto indent(低级)) 虽然低级你知道它多重要么> >
    • on B(bak file)
    • off A(auto save) 〔10_|+|-〕
  • [tab3] 字体和颜色
    • off U(sysmono)
    • [^] use Monaco 12
    • ColorScheme > Oblivion

可用程度

和notepad++类似.

阶段2

这时我的主要编辑器还是sublime text+codeblocks

不爽codeblocks配色很久了> >开始下定决心用gedit

然后打开[tab4],发现了一堆好东西,全都勾上> >

然后去找了一下gedit下的solarized dark配色,找到了> >装上

然后写了一堆snippets和external tools(有些是后来补的也一起列进来咯)

snippets

__LAN C/CPP__

name: debugger     sc: C-'
__SNP__
printf("BP${1:1}\n");
fflush(stdout);
__END__

name:djset         sc: C-3
__SNP__
struct djset{
	int fa[${1:size}];
	int find(int a){return fa[a]?fa[a]=find(fa[a]):a;}
	inline int merge(int a,int b){return ((a=find(a))==(b=find(b)))?-1:fa[b]=a;}
};
__END__

name:hash          sc: C-1
__SNP__
#define hashmod 3001001
inline int hash(int n){
	return ((n*405347)&1073741823)%hashmod;
}
__END__

name:hashmap       sc: C-2
__SNP__
struct __hash{
	#define hashmod 3001001
	inline int hash(int n){
		return ((n*405347)&1073741823)%hashmod;
	}
	int n[hashmod][3],h[hashmod],len;
	inline int find(int n){
		int p=hash(n);
		int q=h[p];
		while(p&&n[p][0]!=n) p=n[p][2];
		return p?n[p][1]:-1;
	}
	inline void ins(int n,int p){
		++len;
		int q=hash(n);
		n[len][0]=n,n[len][1]=p,n[len][2]=h[n],h[n]=len;
	}
} hashmap;
__END__

name:main         sc: C-m
__SNP__
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#define fon(i,s)    for(int i=0;i<s; ++i)
#define fone(i,s)   for(int i=0;i<=s;++i)
#define fox(i,f,t)  for(int i=f;i<t; ++i)
#define foxe(i,f,t) for(int i=f;i<=t;++i)
#define fdn(i,s)    for(int i=s;i;   --i)
#define fdne(i,s)   for(int i=s;~i;  --i)
#define fdx(i,f,t)  for(int i=f;i>t; --i)
#define fdxe(i,f,t) for(int i=f;i>=t;--i)
#define pi 3.14159265358979323846264
#define ifnext(a,b) (((a)-1)&b)
#define home home
#define qbs 60000
typedef long long ll;
typedef unsigned long long ull;
typedef int il;
typedef unsigned int ul;
inline char getc(){ static char buf[qbs];static int q=qbs; if(qbs==q) fread(buf,qbs,1,stdin),q=0; return buf[q++]; }
inline void readuint(ul& a){ a=0; char p=getc(); while(p>'9' || p<'0') p=getc(); while(p<='9'&&p>='0') a=a*10+p-'0',p=getc(); }
inline void readuint(ull& a){ a=0; char p=getc(); while(p>'9' || p<'0') p=getc(); while(p<='9'&&p>='0') a=a*10+p-'0',p=getc(); }
inline void putc(char p,bool e=0){ static char buf[qbs+10];static int q=0; if(~p) buf[q++]=p; if(e&&q || qbs==q) fwrite(buf,q,1,stdout),q=0; }
inline void printuint(ul a){if(a>=10) printuint(a/10); putc(a%10+'0');}
inline void printuint(ull a){if(a>=10) printuint(a/10); putc(a%10+'0');}inline ull ladd(ull a,ull b,ull p){ return a+=b,a=a-ifnext(a>b,p),a-ifnext(a>p,p); }
inline ull lmul(ull a,ull b,ull p){ return (a*b-((ull)((long double)a*b/p)*p)); }
inline ull lpow(ull a,ull b,ull p){ ull k=1; for(;b;b>>=1,a=lmul(a,a,p)) if(b&1) k=lmul(k,a,p); return k; }
inline ull lfpm(ull a,ull b,ull p){ ull k=1; for(;b;b>>=1,a=a*a%p) if(b&1) k=k*a%p; return k; }
inline ul lmul(ul a,ul b,ul p){ return (ull)a*b%p; }
inline ul lfpm(ul a,ul b,ul p){ ul k=1;for(;b;b>>=1,a=lmul(a,a,p)) if(b&1) k=lmul(k,a,p); return k;}
inline void linv(ul* q,ul p,ul m){ q[1]=1; foxe(i,2,p) q[i]=((ull)(m-m/i)*q[m%i])%m; }
void work(){
	${3:/*do some stuff*/}
}
int main(){
#ifndef home
	freopen("${1:file}.in","r",stdin);
	freopen("${1:file}.out","w",stdout);
#endif
	int t;
	${2:scanf("%d",&t);}
	${4:while(t--) work();}
	return 0;
}
__END__

External tools

#NAME: fm-here sc: C-A-f sv:none in:none out:TO lan:AL
#!/bin/sh
EHOME=`echo $HOME | sed "s/#/\#/"`
DIR=$GEDIT_CURRENT_DOCUMENT_DIR
nautilus $DIR/
#NAME: term-here sc: C-A-m sv:none in:none out:TO lan:AL
#!/bin/sh
EHOME=`echo $HOME | sed "s/#/\#/"`
DIR=$GEDIT_CURRENT_DOCUMENT_DIR
gnome-terminal --working-directory=$DIR
#NAME: build sc: S-F9 sv:recent in:none out:TO lan:C/C++
#!/bin/sh
fullname=$GEDIT_CURRENT_DOCUMENT_NAME
name=`echo $fullname | cut	-d. -f1`
suff=`echo $fullname | cut	-d. -f2`
if [ $suffix = "c" ]; then
	gcc $fullname -o $name -g -O2 -Wall -std=gnu99
else
	g++ $fullname -o $name -g -O2 -Wall -std=c++11
fi
#NAME: test sc: C-t sv:recent in:none out:TO lan:C/C++
#!/bin/sh
ulimit -s unlimited
fullname=$GEDIT_CURRENT_DOCUMENT_NAME
name=`echo $fullname | cut	-d. -f1`
suff=`echo $fullname | cut	-d. -f2`
if [ $suffix = "c" ]; then
	gcc $fullname -o $name -g -O2 -std=gnu99
else
	g++ $fullname -o $name -g -std=c++11
fi

echo Compiled
echo ''
timeout 5 /usr/bin/time -v --output=timeres.txt ./$name<$name.in > $name.out
if [ $? = 124 ]; then
	echo Timeout and terminated
fi
cat timeres.txt
cat $name.out
#NAME: testus sc: S-C-t sv:recent in:none out:TO lan:C/C++
#!/bin/sh
ulimit -s unlimited
fullname=$GEDIT_CURRENT_DOCUMENT_NAME
name=`echo $fullname | cut	-d. -f1`
suff=`echo $fullname | cut	-d. -f2`
if [ $suffix = "c" ]; then
	gcc $fullname -o $name -g -O2 -std=gnu99
else
	g++ $fullname -o $name -g -O3 -march=native -std=c++11
fi

echo Compiled
echo ''
timeout 15 /usr/bin/time -v --output=timeres.txt ./$name<$name.in > $name.out
if [ $? = 124 ]; then
	echo Timeout and terminated
fi
cat timeres.txt

阶段三

已经用惯了gedit停不下来了> >

感觉C++配色好丑...符号和括号颜色都没有> >

发现没有匹配的方法,自己自定义了c.lang和一个配色方案

c.lang

<?xml version="1.0" encoding="UTF-8"?>
<!--

 This file is part of GtkSourceView

 Authors: Marco Barisione, Emanuele Aina
 Copyright (C) 2005-2007 Marco Barisione <barisione@gmail.com>
 Copyright (C) 2005-2007 Emanuele Aina

 GtkSourceView is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation; either
 version 2.1 of the License, or (at your option) any later version.

 GtkSourceView 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
 Lesser General Public License for more details.

 You should have received a copy of the GNU Lesser General Public
 License along with this library; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

-->
<language id="c" _name="C" version="2.0" _section="Sources">
  <metadata>
    <property name="mimetypes">text/x-c;text/x-csrc;image/x-xpixmap</property>
    <property name="globs">*.c</property>
    <property name="line-comment-start">//</property>
    <property name="block-comment-start">/*</property>
    <property name="block-comment-end">*/</property>
  </metadata>

  <styles>
    <style id="comment"           _name="Comment"               map-to="def:comment"/>
    <style id="string"            _name="String"                map-to="def:string"/>
    <style id="preprocessor"      _name="Preprocessor"          map-to="def:preprocessor"/>
    <style id="common-defines"    _name="Common Defines"        map-to="def:special-constant"/>
    <style id="included-file"     _name="Included File"         map-to="def:string"/>
    <style id="char"              _name="Character"             map-to="def:character"/>
    <style id="keyword"           _name="Keyword"               map-to="def:keyword"/>
    <style id="operator"          _name="Operator"              map-to="def:operator"/>
    <style id="bracket"          _name="Bracket"              map-to="def:bracket"/>
    <style id="type"              _name="Data Type"             map-to="def:type"/>
    <style id="storage-class"     _name="Storage Class"         map-to="def:type"/>
    <style id="printf"            _name="printf Conversion"     map-to="def:special-char"/>
    <style id="escaped-character" _name="Escaped Character"     map-to="def:special-char"/>
    <style id="floating-point"    _name="Floating point number" map-to="def:floating-point"/>
    <style id="decimal"           _name="Decimal number"        map-to="def:decimal"/>
    <style id="octal"             _name="Octal number"          map-to="def:base-n-integer"/>
    <style id="hexadecimal"       _name="Hexadecimal number"    map-to="def:base-n-integer"/>
    <style id="boolean"           _name="Boolean value"         map-to="def:boolean"/>
    <style id="standard-stream"   _name="Standard stream"       map-to="def:constant"/>
    <style id="signal-name"       _name="Signal name"           map-to="def:constant"/>
    <style id="error"             _name="Error"                 map-to="def:error"/>
  </styles>

  <definitions>

    <!--regexs-->
    <define-regex id="preproc-start">^\s*#\s*</define-regex>
    <define-regex id="escaped-character" extended="true">
      \\(                   # leading backslash
      [\\\"\'nrbtfav\?] |   # escaped character
      [0-7]{1,3} |          # one, two, or three octal digits
      x[0-9A-Fa-f]+         # 'x' followed by hex digits
      )
    </define-regex>

    <!--contexts NOT used on the main context-->
    <!-- TODO: what about scanf ? -->
    <!-- man 3 printf -->
    <context id="printf" style-ref="printf" extend-parent="false">
      <match extended="true">
        \%\%|\%
        (?:[1-9][0-9]*\$)?      # argument
        [#0\-\ \+\'I]*          # flags
        (?:[1-9][0-9]*|\*)?     # width
        (?:\.\-?(?:[0-9]+|\*))? # precision
        (?:hh|ll|[hlLqjzt])?    # length modifier
        [diouxXeEfFgGaAcsCSpnm] # conversion specifier
      </match>
    </context>

    <!--contexts used on the main context-->
    <!-- Preprocessor -->
    <context id="if0-comment" style-ref="comment">
      <start>\%{preproc-start}if\b\s*0\b</start>
      <end>\%{preproc-start}(endif|else|elif)\b</end>
      <include>
        <context id="if-in-if0">
          <start>\%{preproc-start}if(n?def)?\b</start>
          <end>\%{preproc-start}endif\b</end>
          <include>
            <context ref="if-in-if0"/>
            <context ref="def:in-comment"/>
          </include>
        </context>
        <context ref="def:in-comment"/>
      </include>
    </context>

    <context id="include" style-ref="preprocessor">
      <match extended="true">
        \%{preproc-start}
        (include|import)\s*
        (".*?"|&lt;.*&gt;)
      </match>
      <include>
        <context id="included-file" sub-pattern="2" style-ref="included-file"/>
      </include>
    </context>

    <context id="preprocessor" style-ref="preprocessor" end-at-line-end="true">
      <start extended="true">
        \%{preproc-start}
        (define|undef|error|pragma|ident|if(n?def)?|else|elif|endif|line|warning)
        \b
      </start>
      <include>
        <context ref="def:line-continue" ignore-style="true"/>
        <context ref="string" ignore-style="true"/>
        <context ref="def:c-like-comment"/>
        <context ref="def:c-like-comment-multiline"/>
      </include>
    </context>

    <context id="string" style-ref="string" end-at-line-end="true" class="string" class-disabled="no-spell-check">
      <start>L?"</start>
      <end>"</end>
      <include>
        <context ref="printf"/>
        <context id="escaped-character" style-ref="escaped-character">
          <match>\%{escaped-character}</match>
        </context>
        <context ref="def:line-continue"/>
      </include>
    </context>

    <context id="char" style-ref="char">
      <match>L?'(\%{escaped-character}|.)'</match>
    </context>

    <!-- http://www.lysator.liu.se/c/ANSI-C-grammar-l.html -->
    <context id="float" style-ref="floating-point">
      <match extended="true">
        (?&lt;![\w\.])
        ((\.[0-9]+ | [0-9]+\.[0-9]*) ([Ee][+-]?[0-9]*)? |
         ([0-9]+[Ee][+-]?[0-9]*))
        [fFlL]?
        (?![\w\.])
      </match>
    </context>

    <context id="hexadecimal" style-ref="hexadecimal">
      <match extended="true">
        (?&lt;![\w\.])
        0[xX][a-fA-F0-9]+[uUlL]*
        (?![\w\.])
      </match>
    </context>

    <context id="invalid-hexadecimal" style-ref="error">
      <match extended="true">
        (?&lt;![\w\.])
        0[xX][a-fA-F0-9]*[g-zG-Z][a-zA-Z0-9]*[uUlL]*
        (?![\w\.])
      </match>
    </context>

    <context id="octal" style-ref="octal">
      <match extended="true">
        (?&lt;![\w\.])
        0[0-7]+[uUlL]*
        (?![\w\.])
      </match>
    </context>

    <context id="invalid-octal" style-ref="error">
      <match extended="true">
        (?&lt;![\w\.])
        0[0-7]*[89][0-9]*[uUlL]*
        (?![\w\.])
      </match>
    </context>

    <context id="decimal" style-ref="decimal">
      <match extended="true">
        (?&lt;![\w\.])
        (0|[1-9][0-9]*)[uUlL]*
        (?![\w\.])
      </match>
    </context>

    <context id="keywords" style-ref="keyword">
      <keyword>asm</keyword>
      <keyword>break</keyword>
      <keyword>case</keyword>
      <keyword>continue</keyword>
      <keyword>default</keyword>
      <keyword>do</keyword>
      <keyword>else</keyword>
      <keyword>enum</keyword>
      <keyword>for</keyword>
      <keyword>fortran</keyword>
      <keyword>goto</keyword>
      <keyword>if</keyword>
      <keyword>return</keyword>
      <keyword>struct</keyword>
      <keyword>switch</keyword>
      <keyword>typedef</keyword>
      <keyword>union</keyword>
      <keyword>while</keyword>
    </context>

    <context id="operators" style-ref="operator">
      <match extended="true">
        (\+ | \- | \* | \/ | \^ | \= | &gt; | &lt; | &amp; | \|)
      </match>
    </context>
    
    <context id="brackets" style-ref="bracket">
    	<match extended="true">
    	( \( | \) | \[ | \] | \{ | \} )
    	</match>
    </context>

    <context id="types" style-ref="type">
      <keyword>_Bool</keyword>
      <keyword>_Complex</keyword>
      <keyword>_Imaginary</keyword>
      <keyword>bool</keyword>
      <keyword>char</keyword>
      <keyword>double</keyword>
      <keyword>float</keyword>
      <keyword>int</keyword>
      <keyword>(u)?int(8|16|32|64)_t</keyword>
      <keyword>long</keyword>
      <keyword>ptrdiff_t</keyword>
      <keyword>off(64)?_t</keyword>
      <keyword>short</keyword>
      <keyword>signed</keyword>
      <keyword>size_t</keyword>
      <keyword>ssize_t</keyword>
      <keyword>unsigned</keyword>
      <keyword>void</keyword>
      <keyword>wchar_t</keyword>
      <keyword>wint_t</keyword>
    </context>

    <context id="storage-class" style-ref="storage-class">
      <keyword>auto</keyword>
      <keyword>const</keyword>
      <keyword>extern</keyword>
      <keyword>inline</keyword>
      <keyword>register</keyword>
      <keyword>restrict</keyword>
      <keyword>static</keyword>
      <keyword>volatile</keyword>
    </context>

    <!-- C99 booleans -->
    <context id="boolean" style-ref="boolean">
      <keyword>true</keyword>
      <keyword>false</keyword>
    </context>

    <context id="common-defines" style-ref="common-defines">
      <keyword>NULL</keyword>
      <keyword>MAX</keyword>
      <keyword>MIN</keyword>
      <keyword>TRUE</keyword>
      <keyword>FALSE</keyword>
      <keyword>__LINE__</keyword>
      <keyword>__DATA__</keyword>
      <keyword>__FILE__</keyword>
      <keyword>__func__</keyword>
      <keyword>__TIME__</keyword>
      <keyword>__STDC__</keyword>
    </context>

    <context id="standard-streams" style-ref="standard-stream">
      <keyword>stdin</keyword>
      <keyword>stdout</keyword>
      <keyword>stderr</keyword>
    </context>

    <context id="signals" style-ref="signal-name">
      <keyword>SIGABRT</keyword>
      <keyword>SIGALRM</keyword>
      <keyword>SIGCHLD</keyword>
      <keyword>SIGCONT</keyword>
      <keyword>SIGFPE</keyword>
      <keyword>SIGHUP</keyword>
      <keyword>SIGILL</keyword>
      <keyword>SIGINT</keyword>
      <keyword>SIGKILL</keyword>
      <keyword>SIGPIPE</keyword>
      <keyword>SIGQUIT</keyword>
      <keyword>SIGSEGV</keyword>
      <keyword>SIGSTOP</keyword>
      <keyword>SIGTERM</keyword>
      <keyword>SIGTRAP</keyword>
      <keyword>SIGTSTP</keyword>
      <keyword>SIGTTIN</keyword>
      <keyword>SIGTTOU</keyword>
      <keyword>SIGUSR1</keyword>
      <keyword>SIGUSR2</keyword>
    </context>

    <!--Main context-->
    <context id="c" class="no-spell-check">
      <include>
        <context ref="gtk-doc:inline-docs-section"/>
        <context ref="def:c-like-comment"/>
        <context ref="def:c-like-comment-multiline"/>
        <context ref="def:c-like-close-comment-outside-comment"/>
        <context ref="if0-comment"/>
        <context ref="include"/>
        <context ref="preprocessor"/>
        <context ref="string"/>
        <context ref="char"/>
        <context ref="float"/>
        <context ref="hexadecimal"/>
        <context ref="invalid-hexadecimal"/>
        <context ref="octal"/>
        <context ref="invalid-octal"/>
        <context ref="decimal"/>
        <context ref="keywords"/>
        <context ref="operators"/>
        <context ref="brackets"/>
        <context ref="types"/>
        <context ref="storage-class"/>
        <context ref="boolean"/>
        <context ref="common-defines"/>
        <context ref="standard-streams"/>
        <context ref="signals"/>
      </include>
    </context>

  </definitions>
</language>

配色ubistive.xml(其实乱取的名)

<?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>

改自solarized-dark,大家都懂的

效果图

posted @ 2015-08-11 21:24  zball  阅读(3044)  评论(1编辑  收藏  举报