Showing posts with label editor. Show all posts
Showing posts with label editor. Show all posts

Friday, February 1, 2013

ldapvi - ldap client using text editor

Today I stumbled upon a good tool in managing ldap, which is ldapvi. The reason this tool champs over my previous ldap management tool, which is phpldapadmin, is, it is based on text editor, and can be used in terminal ~ cool :)

To install this tool, all you need is to use your package manager, in my case, yum:

$ sudo yum install ldapvi

Once you have finished installing, launch it with your username and ldap server:

$ sudo ldapvi --user cn=admin,ou=people,dc=local,dc=lan  --host ldap.local.lan

For first time use, you need to set your preferred text editor. Once logged in, you can change the ldap record as if you are working on a very long text file. Once you are done, save like how you normally save a text file, ldapvi will ask for confirmation, and you are done.


Tuesday, December 18, 2012

Searching in vim with ignorecase on

This is for searching any string in vi or vim, regardless of the case. All you need to do is to press

/\c
while you are in vim followed by your pattern to start this ignore case search. For example, if you  have a list like below:

Miu
MIu
MiU
mIU

and search in vim using
/\cmiu
, vi will list every line as the search output, even though the cases are different. try it :)


Thursday, September 29, 2011

Replacing space with newline

There are a few ways to achieve that:

1. sed

$ echo "one two three" | sed 's/ /\n/g'
one
two
three
2. awk
$ echo "one two three" | awk '$1=$1' RS= OFS="\n"
one
two
three
3. tr
$ echo "one two three" | tr -s ' ' '\n'
one
two
three
3 ways to do it, have fun

Friday, February 4, 2011

vim comment lines

In linux, while editing configuration files, we always used # sign for comments. How do we do it to multiple lines in vi easily?

Steps:

1. Edit the files using vi
$ vi files.conf

2. set line number in vi (for us to easily determine what is the line number that we want to edit)
:se nu

3. replace start of lines with # (for example, put # sign in front of line 2 to line 5). The meaning of below command is for line 2 - 5, subtitute (s) start of line (^) with # sign, and press enter
:2,5s/^/#/
<enter>

4. It is done. Save your file (w) and quit (q)
:wq

Tuesday, March 25, 2008

Using tab in vi and vim

The new version of vi and vim supports tab function. Make sure your vi and vim version is 7.0 and above to do this. To open new tab, run :tabnew or :tabe in normal mode. T open a file in new tab, use :tabnew filename or :tabe filename. To move between tab, use ctrl+pgup and ctrl+pgdown. You can also use gt to and gT to move between tabs. To move to specific tab number use igt where i is the tab number. To list all the tabs created, use :tabs.

Picture shows tabs in vi

Thursday, July 12, 2007

Setting default editor in ubuntu

To change the default editor for your ubuntu machine, here is the step:

  1. type:
    • $ update-alternatives --config editor
  2. Select which editor that you want to set as default by typing its number. For below example, vim(1) is chosen.



Another method to do the similar task is by using command select-editor:

1. type the command
$ select-editor
Select an editor. To change later, run 'select-editor'.
1. /usr/bin/vim.tiny
2. /bin/ed
3. /bin/nano <---- easiest

Choose 1-3 [3]:

2. Choose from the list given. In the case above, if you want vim to be your default editor, type '1' and press 'enter'

3. Finish