PuTTy模板
  • 板块学术版
  • 楼主juruo_zhanshen
  • 当前回复0
  • 已保存回复0
  • 发布时间2023/10/28 22:52
  • 上次更新2023/11/2 10:59:23
查看原帖
PuTTy模板
928326
juruo_zhanshen楼主2023/10/28 22:52

这是我自己坐的一些模板,可以帮助大家很好的使用putty。 教大家如何更改自己的模板。

  1. 在 home 目录里打出 cd .vim。

  2. 输入 vim c-support/templates/c.idioms.template指令。

  3. 将以下代码复制进打开的文件里。


== Idioms.intfunction == map:iif, shortcut:if  ==
/*
 * ===  FUNCTION  ======================================================================
 *         Name:  |?FUNCTION_NAME|
 *  Description:  int function
 * =====================================================================================
 */
int |FUNCTION_NAME|(<CURSOR>)
{

}               /* -----  end of function |FUNCTION_NAME|  ----- */

== Idioms.voidfunction == map:ivf, shortcut:vf  ==
/*
 * ===  FUNCTION  ======================================================================
 *         Name:  |?FUNCTION_NAME|
 *  Description:  void function
 * =====================================================================================
 */
void |FUNCTION_NAME|(<CURSOR>)
{

}               /* -----  end of function |FUNCTION_NAME|  ----- */

== Idioms.boolfunction == map:ibf, shortcut:bf  ==
/*
 * ===  FUNCTION  ======================================================================
 *         Name:  |?FUNCTION_NAME|
 *  Description:  bool function
 * =====================================================================================
 */
bool |FUNCTION_NAME|(<CURSOR>)
{

}               /* -----  end of function |FUNCTION_NAME|  ----- */

== Idioms.function == map:idf, shortcut:df  ==
/*
 * ===  FUNCTION  ======================================================================
 *         Name:  |?FUNCTION_NAME|
 *  Description:  double function
 * =====================================================================================
 */
double |FUNCTION_NAME|()
{
<CURSOR>
}               /* -----  end of function |FUNCTION_NAME|  ----- */


== Idioms.function-static == map:isf, shortcut:t  ==
/*
 * ===  FUNCTION  ======================================================================
 *         Name:  |?FUNCTION_NAME|
 *  Description:
 * =====================================================================================
 */
static void<CURSOR> |FUNCTION_NAME|()
{
}               /* -----  end of static function |FUNCTION_NAME|  ----- */

== Idioms.main == map:im, shortcut:m  ==
#include <bits/stdc++.h>

using namespace std;
/*
 * ===  FUNCTION  ======================================================================
 *         Name:  main
 *  Description:
 * =====================================================================================
 */
int main ( int argc, char *argv[] )
{ <CURSOR>
    //freopen("|?FILENAME|.in", "r", stdin);
    //freopen("|FILENAME|.out", "w", stdout);
<SPLIT> return 0;
}                               /* ----------  end of function main  ---------- */



== Idioms.enum == map:ie, shortcut:e  ==
typedef enum _|?ENUM_NAME|
{<CURSOR>
<SPLIT>} |ENUM_NAME|;                           /* ----------  end of enum |ENUM_NAME|  ---------- */

== Idioms.struct == map:is, shortcut:s  ==
struct |?STRUCT_NAME|
{
    <CURSOR>
<SPLIT>};                               /* ----------  end of struct |STRUCT_NAME|  ---------- */

== Idioms.union == map:iu, shortcut:u  ==
typedef union _|?UNION_NAME|
{<CURSOR>
<SPLIT>} |UNION_NAME|;                          /* ----------  end of union |UNION_NAME|  ---------- */

== Idioms.callback == map:icb, shortcut:b  ==
typedef void ( * |?CALLBACK_NAME| )( <CURSOR> );

== Idioms.scanf == map:isc, shortcut:s, insert  ==
scanf ( "<CURSOR>", & );
== Idioms.printf == map:ipr, shortcut:p, insert  ==
printf ( "<CURSOR>\n" );
== Idioms.calloc == map:ica, shortcut:c  ==
|?POINTER|      = calloc ( (size_t)(<CURSOR><+COUNT+>), sizeof(<+TYPE+>) );
if ( |POINTER|==NULL ) {
        fprintf ( stderr, "\ndynamic memory allocation failed\n" );
        exit (EXIT_FAILURE);
}

free (|POINTER|);
|POINTER|       = NULL;

== Idioms.malloc == map:ima, shortcut:m  ==
|?POINTER|      = malloc ( sizeof(<CURSOR><+TYPE+>) );
if ( |POINTER|==NULL ) {
        fprintf ( stderr, "\ndynamic memory allocation failed\n" );
        exit (EXIT_FAILURE);
}

free (|POINTER|);
|POINTER|       = NULL;

== Idioms.realloc == map:ire, shortcut:r  ==
|?POINTER|      = realloc ( |POINTER|, sizeof(<CURSOR><+TYPE+>) );
if ( |POINTER|==NULL ) {
        fprintf ( stderr, "\ndynamic memory reallocation failed\n" );
        exit (EXIT_FAILURE);
}

== Idioms.sizeof == map:isi, shortcut:s, insert  ==
sizeof(<CURSOR><SPLIT>)
== Idioms.assert == map:ias, shortcut:a, insert  ==
assert(<CURSOR><SPLIT>);
== Idioms.open-input-file == map:ii, shortcut:i  ==
FILE    *|?FILEPOINTER|;                                                                                /* input-file pointer */
char    *|FILEPOINTER|_file_name = "<CURSOR>";          /* input-file name    */

|FILEPOINTER|   = fopen( |FILEPOINTER|_file_name, "r" );
if ( |FILEPOINTER| == NULL ) {
        fprintf ( stderr, "couldn't open file '%s'; %s\n",
                        |FILEPOINTER|_file_name, strerror(errno) );
        exit (EXIT_FAILURE);
}
<SPLIT>{-continue_here-}
if( fclose(|FILEPOINTER|) == EOF ) {                    /* close input file   */
        fprintf ( stderr, "couldn't close file '%s'; %s\n",
                        |FILEPOINTER|_file_name, strerror(errno) );
        exit (EXIT_FAILURE);
}

== Idioms.open-output-file == map:io, shortcut:o  ==
FILE    *|?FILEPOINTER|;                                                                                /* output-file pointer */
char    *|FILEPOINTER|_file_name = "<CURSOR>";          /* output-file name    */

|FILEPOINTER|   = fopen( |FILEPOINTER|_file_name, "w" );
if ( |FILEPOINTER| == NULL ) {
        fprintf ( stderr, "couldn't open file '%s'; %s\n",
                        |FILEPOINTER|_file_name, strerror(errno) );
        exit (EXIT_FAILURE);
}
<SPLIT>{-continue_here-}
if( fclose(|FILEPOINTER|) == EOF ) {                    /* close output file   */
        fprintf ( stderr, "couldn't close file '%s'; %s\n",
                        |FILEPOINTER|_file_name, strerror(errno) );
        exit (EXIT_FAILURE);
}

== Idioms.fprintf == map:ifsc, shortcut:f, insert  ==
fprintf ( |?FILEPOINTER|, "<CURSOR>\n",  );
== Idioms.fscanf == map:ifpr, shortcut:f, insert  ==
fscanf ( |?FILEPOINTER|, "<CURSOR>", & );#include <bits/stdc++.h>
using namespace std;

long long fib(int n){
    if (n <= 1){
        return n;
    }
    long long tmp = fib(n - 1) + fib(n - 2);
    cout << tmp % (long long)(pow(10, 9) + 7);
    return tmp;
}

long long p(long long a, long long n){
    while (n > 0){
        long long tmp = a % n;
        a = n;
        n = tmp;
    }
    return a;
}
int main(){
    fib(pow(2, 63));
}

== Idioms.quick_pow == map:qpf, shortcut:qp  ==
/*
 * ===  FUNCTION  ======================================================================
 *         Name:  quick_pow
 *  Description:  int function
 * =====================================================================================
 */
int quick_pow(int a, int n)
{
    if (n == 0) return 1;
    if (n == 1) return a;
    int tmp = quick_pow(a, n >> 1);
    if (n & 1) return a * tmp * tmp;
    else return tmp * tmp;
}               /* -----  end of function quick_pow  ----- */

== Idioms.read == map:read, shortcut:rd  ==
/*
 * ===  FUNCTION  ======================================================================
 *         Name:  read
 *  Description:  int function
 * =====================================================================================
 */
void read(int & a)
{
        int x = 0, f = 1;
    char ch = getchar();
        while (ch < '0' || ch > '9'){ if (ch == '-') f = -1; ch = getchar(); }
        while (ch >= '0' && ch <= '9'){ x = x * 10 + ch - 48; ch = getchar(); }
        a = x * f;
}

== Idioms.write == map:write, shortcut:wrt  ==
/*
 * ===  FUNCTION  ======================================================================
 *         Name:  write
 *  Description:  int function
 * =====================================================================================
 */
void write(int x)
{
    if(x < 0)
        putchar('-'), x = -x;
    if(x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}

相信各位一定能看懂。

其实,第一行的 == Idioms.intfunction == map:iif, shortcut:if ==。

可以在INSERT模式下打出\iif,即可获得int类型函数的模板,这里还有快读快写和快速幂。希望对大家带来帮助。

2023/10/28 22:52
加载中...