Welcome Guest, Not a member yet? Register   Sign In
Notepad++ Snippets
#1

[eluser]Michael Wales[/eluser]
I've recently become acquainted with Snippets thanks to giving eTextEditor and InType a try. Although the snippet functionality within these applications is much more powerful than the QuickText plugin provided with Notepad++ - those application just didn't "feel" right.

So, I took some time out tonight to create a snippet file for myself. This doesn't include every library within CodeIgniter - just the ones I use quite often.

If you would like to use these Snippets, copy-paste the text below at the top C:\Program Files\Notepad++\QuickText.ini file:

Code:
[1]
a=<?= anchor('$', '$'); ?>
cfgitem=\$this->config->item('$')
cfgset=\$this->config->set_item('$', '$')
ci_c=class $ extends Controller {\n\n    function __construct() {\n        parent::Controller();\n    }\n\n    function index() {\n        $\n    }\n\n}
ci_m=class $_m extends Model {\n\n    function __construct() {\n        parent::Model();\n    }\n\n    $\n\n}
dbcount=\$this->db->count_all('$');
dbdelete=\$this->db->delete('$', array($));
dbfrom=\$this->db->from('$');
dbget=\$this->db->get('$');
dbgetwhere=\$this->db->getwhere('$', array($));
dbgroup=\$this->db->groupby(array($));
dbhaving=\$this->db->having(array($));
dbinsert=\$insert = array($);\n\n\$this->db->insert('$', \$insert);
dbjoin=\$this->db->join('$', '$');
dblike=\$this->db->like(array($));
dblimit=\$this->db->limit($);
dborder=\$this->db->orderby('$');
dborlike=\$this->db->orlike(array($));
dborwhere=\$this->db->orwhere(array($));
dbselect=\$this->db->select('$');
dbset=\$this->db->set(array($));
dbupdate=\$update = array($);\n\n\$this->db->update('$', \$update);
dbwhere=\$this->db->where('$', array($));
e=echo '$';
email=\$msg = $;\n\n\$this->email->from('$', '$');\n\$this->email->to('$');\n\$this->email->subject('$');\n\$this->email->message(\$msg);\n\$this->email->send();
f=function $($) {\n    $\n}
f_=function _$($) {\n    $\n}
for=for ($, $, $) {\n    $\n}
foreach=foreach ($ as $) {\n    $\n}
form=<?= form_open('$'); ?>\n    $\n<?= form_close(); ?>
formm=<?= form_open_multipart('$'); ?>\n    $\n<?= form_close(); ?>
if=if ($) {\n    $\n}
ifelse=if ($) {\n    $\n} else {\n    $\n}
ifelseif=if ($) {\n    $\n} elseif ($) {\n    $\n} else {\n    $\n}
loadconfig=\$this->load->config('$');
loadhelper=\$this->load->helper('$');
loadlang=\$this->load->lang('$');
loadlib=\$this->load->library('$');
loadplugin=\$this->load->plugin('$');
loadview=\$this->load->view('$');
md5=\$this->security->dohash('$', 'md5');
p?=<?= $; ?>
php=<?php if (!defined('BASEPATH')) exit('No direct script access allowed');\n\n$\n\n?>
post=\$this->input->post('$');
r=redirect('$');
sdata=\$this->input->session('$');
sha1=\$this->security->dohash('$');
ssetdata=\$this->session->set_userdata(array($));
switch=switch ($) {\n    case '$':\n        $\n    default:\n        $\n}
upload=\$config['upload_path'] = '$';\n\$config['allowed_types'] = '$';\n\$this->load->library('upload', '\$config');\n\nif ($this->upload->do_upload()) {\n    $\n} else {\n    $\n}
val=if (\$this->validation->run()) {\n    $\n} else {\n    $\n}
valfield=\$fields['$'] = '$';
valrule=\$rules['$'] = '$';
valsetfields=\$this->validation->set_fields(\$fields);
valsetrule=\$this->validation->set_rules(\$rules);
while=while ($) {\n    $\n}


I was going to write out documentation for each of the shortcuts but it will take forever. Basically, review the text above - everything on the far left of the equal sign is the keyword, everything on the right is what will replace that keyword when you use the ctrl+enter combination.

I will be creating a PDF that can be printed out as a cheat sheet for these snippets. Once we have that and you spend some time with them and learn them, this should speed up your development significantly.
#2

[eluser]xwero[/eluser]
Maybe you can add the html doctype too Wink
#3

[eluser]Majd Taby[/eluser]
haha I was working on the same exact thing for vim two days ago, you've got quite a few more though, thanks for sharing.
#4

[eluser]Michael Wales[/eluser]
Haha - I so thought of making an HTML snippet. I guess I've been in a lazy mood lately and trying to minimize my typing as much as possible Sad
#5

[eluser]xwero[/eluser]
Typing is the least fun part of the job. Maybe you should buy a speech-to-text application so you get rid of the typing all together.
#6

[eluser]Unknown[/eluser]
Hi!

I don't know why, but I can't use snippet with underscore.
When I try to use ci_c, there's the message: Only alphanumerical characters.

Do you know how to resolve this?

Thanks!
#7

[eluser]Michael Wales[/eluser]
Yeah - it happens sometimes with me as well. I intend to change those snippets to remove the underscore.

It's kind of hit-or-miss, doesn't happen all the time.
#8

[eluser]Ivan A. Zenteno[/eluser]
Yeah!! It's working, thank you for make it

But I did eliminated underscores in ci_c and ci_m.
I have working well cic and cim

p.d. sorry for my bad english :$
#9

[eluser]benoa[/eluser]
Thanks a lot. That's a real time saver.
#10

[eluser]cliffoliveira[/eluser]
Thanks a lot. That’s a real time saver. (2)




Theme © iAndrew 2016 - Forum software by © MyBB